Tutorial~15 MinutenAußerhalb 3.5.0-Stable

OAuth2 / OpenID Connect

OAuth2, OIDC und MFA. Stable 3.5.0 bleibt @Auth / @Role auf Rust/Axum.

Was du lernen wirst

  • @OAuth2 und @OIDC
  • MFA-Decorator
  • Config in velin.config.json

Decorators

@OAuth2
@GET("/api/profile")
fn getProfile(): User {
    return currentUser();
}

@OIDC
@GET("/api/userinfo")
fn getUserInfo(): UserInfo {
    return fetchUserInfo();
}

@MFA
@POST("/api/sensitive-action")
fn performSensitiveAction(): ActionResult {
    return executeAction();
}

Config

{
  "auth": {
    "provider": "oauth2",
    "oauth2": {
      "enabled": true,
      "clientId": "${OAUTH2_CLIENT_ID}",
      "clientSecret": "${OAUTH2_CLIENT_SECRET}",
      "authUrl": "https://oauth.provider.com/authorize",
      "tokenUrl": "https://oauth.provider.com/token"
    },
    "oidc": {
      "enabled": true,
      "issuerUrl": "https://oidc.provider.com"
    },
    "mfa": true
  }
}