OIDC Discoveryを使ってアプリケーションを構成する
OpenID Connect(OIDC)Discoveryドキュメントは、IDプロバイダー(IdP)についてのメタデータを含みます。SDKにディスカバリーを追加して、アプリケーションを./wellknown
エンドポイントにポイントし、IdPに関する情報を取得することで、IdPとの統合構成に役立てることができます。
OIDC DiscoveryをSDKに統合すると以下が得られます。
IdPの公開されているエンドポイント
標準のOIDCがサポートするクレームとスコープ(これにはテナントで定義されたカスタムクレームとスコープは含まれません)
IdPがサポートする機能
次のOpenID Connect(OIDC)Discoveryドキュメントを使ってアプリケーションを構成することができます:https://{yourDomain}/.well-known/openid-configuration
応答例
{
"issuer": "https://{yourDomain}.us.auth0.com/",
"authorization_endpoint": "https://{yourDomain}.us.auth0.com/authorize",
"token_endpoint": "https://{yourDomain}.us.auth0.com/oauth/token",
"device_authorization_endpoint": "https://{yourDomain}.us.auth0.com/oauth/device/code",
"userinfo_endpoint": "https://{yourDomain}.us.auth0.com/userinfo",
"mfa_challenge_endpoint": "https://{yourDomain}.us.auth0.com/mfa/challenge",
"jwks_uri": "https://{yourDomain}.us.auth0.com/.well-known/jwks.json",
"registration_endpoint": "https://{yourDomain}.us.auth0.com/oidc/register",
"revocation_endpoint": "https://{yourDomain}.us.auth0.com/oauth/revoke",
"scopes_supported": [
"openid",
"profile",
"offline_access",
"name",
"given_name",
"family_name",
"nickname",
"email",
"email_verified",
"picture",
"created_at",
"identities",
"phone",
"address"
],
"response_types_supported": [
"code",
"token",
"id_token",
"code token",
"code id_token",
"token id_token",
"code token id_token"
],
"code_challenge_methods_supported": [
"S256",
"plain"
],
"response_modes_supported": [
"query",
"fragment",
"form_post"
],
"subject_types_supported": [
"public"
],
"id_token_signing_alg_values_supported": [
"HS256",
"RS256",
"PS256"
],
"token_endpoint_auth_methods_supported": [
"client_secret_basic",
"client_secret_post",
"private_key_jwt"
],
"claims_supported": [
"aud",
"auth_time",
"created_at",
"email",
"email_verified",
"exp",
"family_name",
"given_name",
"iat",
"identities",
"iss",
"name",
"nickname",
"phone_number",
"picture",
"sub"
],
"request_uri_parameter_supported": false,
"request_parameter_supported": false,
"token_endpoint_auth_signing_alg_values_supported": [
"RS256",
"RS384",
"PS256"
]
}
Was this helpful?
実装例
たとえば、以下の方法でKatana v3(OWIN)に対するOIDCミドルウェアを構成します。
NuGetのパッケージをインストールします:Microsoft.Owin.Security.OpenIdConnect(v3.x.x)
App_Start\Startup.Auth.cs
に移動し、実装を以下に置き換えます。codeblockOld.header.login.configureSnippetapp.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = CookieAuthenticationDefaults.AuthenticationType }); app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { Authority = "https://{yourDomain}/", ClientId = "{yourClientId}", SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType, ResponseType = "token", Notifications = new OpenIdConnectAuthenticationNotifications { // OPTIONAL: you can read/modify the claims that are populated based on the JWT SecurityTokenValidated = context => { // add Auth0 Access Token as claim var accessToken = context.ProtocolMessage.AccessToken; if (!string.IsNullOrEmpty(accessToken)) { context.AuthenticationTicket.Identity.AddClaim(new Claim("access_token", accessToken)); } return Task.FromResult(0); } } });
Was this helpful?
/
JWTのRSAアルゴリズム
OIDCミドルウェアは対称鍵で署名されたJWTをサポートしていません。必ず、公開鍵/秘密鍵を使用して、RSAアルゴリズムを使用するようにアプリを構成してください。
[Dashboard]>[Settings(設定)]に移動します。
[Advanced Settings(高度な設定)]までスクロールします。
[OAuth]タブで、
RS256
を[Json Web Token (JWT) Signature Algorithm(JSON Web Token署名アルゴリズム)]に設定し、[Save(保存)]をクリックします。
この設定により、Auth0は秘密署名鍵で署名されたJWTを発行します。アプリはそれらを公開署名鍵で検証します。