OIDC SSO - Discovery Mechanism

简介: ## 背景信息> OIDC SSO相关文档总共4篇,主要内容为对OIDC实现SSO登录流程时的各个细节和相关技术的阐述:1. 《[OIDC SSO - OAuth2.0的授权模式选择](https://ata.alibaba-inc.com/articles/218489)》2. 《[OIDC SSO - 相关SSO流程和注意事项](https://ata.alibaba-inc.com/a

背景信息

OIDC SSO相关文档总共4篇,主要内容为对OIDC实现SSO登录流程时的各个细节和相关技术的阐述:
OIDC实现了一个OpenID Provider服务发现机制,这个时候Relying Party就不需要预先获取太多的OP信息和配置,根据对应的issuer地址就能够获取自己需要的各种端点和协议信息。
This specification defines a mechanism for an OpenID Connect Relying Party to discover the End-User's OpenID Provider and obtain information needed to interact with it, including its OAuth 2.0 endpoint locations.
OIDC Discovery Spec: https://openid.net/specs/openid-connect-discovery-1_0.html
google oidc openid-configuration example address:
https://accounts.google.com/.well-known/openid-configuration

Discovery机制

核心就是每个OP issuer 必须提供一个对应的访问路径:/.well-known/openid-configuration
指定的访问方式必须是http get方式,必须通过application/json格式返回一个JSON文档,提供RP各种支持和需要的信息,如token_endpoint、authorization_endpoint等。

OpenID Providers supporting Discovery MUST make a JSON document available at the path formed by concatenating the string /.well-known/openid-configuration to the Issuer. The syntax and semantics of .well-known are defined in RFC 5785 [RFC5785] and apply to the Issuer value when it contains no path component. openid-configuration MUST point to a JSON document compliant with this specification and MUST be returned using the application/json content type.

If the Issuer value contains a path component, any terminating / MUST be removed before appending /.well-known/openid-configuration. The RP would make the following request to the Issuer https:/ /example.com/issuer1 to obtain its Configuration information, since the Issuer contains a path component:

Discovery中字段解释

下述表格中只包含了必须实现的字段和推荐的一些重要字段解释。
表格很长,查看的时候左右滑动一下。
字段 要求 中文解释 英文原文
issuer REQUIRED OP的身份标识,不可更改。在ID Token中作为iss Claim存在,以此来标识这个token由OP签发。 URL using the https scheme with no query or fragment component that the OP asserts as its Issuer Identifier. If Issuer discovery is supported (see Section 2), this value MUST be identical to the issuer value returned by WebFinger. This also MUST be identical to the iss Claim value in ID Tokens issued from this Issuer.
authorization_endpoint REQUIRED OAuth 2.0的授权端点。 URL of the OP's OAuth 2.0 Authorization Endpoint.
token_endpoint REQUIRED OAuth 2.0的Token端点。隐式流可以没有。 URL of the OP's OAuth 2.0 Token Endpoint. This is REQUIRED unless only the Implicit Flow is used.
userinfo_endpoint RECOMMENDED OP的用户信息端点。 URL of the OP's UserInfo Endpoint. This URL MUST use the https scheme and MAY contain port, path, and query parameter components.
jwks_uri REQUIRED OP使用的JWKs端点,通过这个端点来告知RP对应的签名和加密使用的秘钥key-id和公钥信息,RP根据这个端点来做解密和验签。
秘钥轮转也是基于这个端点来操作。
URL of the OP's JSON Web Key Set [[JWK]](https://openid.net/specs/openid-connect-discovery-1_0.html#JWK) document. This contains the signing key(s) the RP uses to validate signatures from the OP. The JWK Set MAY also contain the Server's encryption key(s), which are used by RPs to encrypt requests to the Server. When both signing and encryption keys are made available, a use (Key Use) parameter value is REQUIRED for all keys in the referenced JWK Set to indicate each key's intended usage. Although some algorithms allow the same key to be used for both signatures and encryption, doing so is NOT RECOMMENDED, as it is less secure. The JWK x5c parameter MAY be used to provide X.509 representations of keys provided. When used, the bare key values MUST still be present and MUST match those in the certificate.
scopes_supported RECOMMENDED Server告知支持哪些Scope,可以选择性的列出支持的Scope。 JSON array containing a list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [[OpenID.Core]](https://openid.net/specs/openid-connect-discovery-1_0.html#OpenID.Core) SHOULD be listed, if supported.
response_types_supported REQUIRED OP支持的各种response type组合。 JSON array containing a list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values.
grant_types_supported OPTIONAL OP支持的授权模式列表,如果不提供,默认值是["authorization_code", "implicit"]。 JSON array containing a list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"].
subject_types_supported REQUIRED 返回public。这个就是Claim中的sub,终端用户的唯一标识是单个实例下唯一,还是每个应用下唯一。
用于防止应用之间做用户信息追踪。
JSON array containing a list of the Subject Identifier types that this OP supports. Valid types include pairwise and public.
id_token_signing_alg_values_supported REQUIRED OP签发的ID Token使用的签名算法。必须包含RS256。 JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT [[JWT]](https://openid.net/specs/openid-connect-discovery-1_0.html#JWT). The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow).
claims_supported RECOMMENDED OP支持在ID Token中签发的Claim列表。 JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list.
request_uri_parameter_supported OPTIONAL 当redirect_uri包含敏感参数,或者对应参数一直固定的情况下, Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is true.
code_challenge_methods_supported OPTIONAL OAuth 2.0 PKCE中支持的challenge计算算法。
token_endpoint_auth_methods_supported OPTIONAL Server支持的授权端点认证算法。
可选值为 client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt
默认值是client_secret_basic。
具体信息参考OIDC SSO进阶。
JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749].

OpenID Configuraiont Example

google

{
    "issuer":"https://accounts.google.com",
    "authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth",
    "device_authorization_endpoint":"https://oauth2.googleapis.com/device/code",
    "token_endpoint":"https://oauth2.googleapis.com/token",
    "userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo",
    "revocation_endpoint":"https://oauth2.googleapis.com/revoke",
    "jwks_uri":"https://www.googleapis.com/oauth2/v3/certs",
    "response_types_supported":[
        "code",
        "token",
        "id_token",
        "code token",
        "code id_token",
        "token id_token",
        "code token id_token",
        "none"
    ],
    "subject_types_supported":[
        "public"
    ],
    "id_token_signing_alg_values_supported":[
        "RS256"
    ],
    "scopes_supported":[
        "openid",
        "email",
        "profile"
    ],
    "token_endpoint_auth_methods_supported":[
        "client_secret_post",
        "client_secret_basic"
    ],
    "claims_supported":[
        "aud",
        "email",
        "email_verified",
        "exp",
        "family_name",
        "given_name",
        "iat",
        "iss",
        "locale",
        "name",
        "picture",
        "sub"
    ],
    "code_challenge_methods_supported":[
        "plain",
        "S256"
    ],
    "grant_types_supported":[
        "authorization_code",
        "refresh_token",
        "urn:ietf:params:oauth:grant-type:device_code",
        "urn:ietf:params:oauth:grant-type:jwt-bearer"
    ]
}

Okta

{
    "issuer":"https://dev-38997354.okta.com",
    "authorization_endpoint":"https://dev-38997354.okta.com/oauth2/v1/authorize",
    "token_endpoint":"https://dev-38997354.okta.com/oauth2/v1/token",
    "userinfo_endpoint":"https://dev-38997354.okta.com/oauth2/v1/userinfo",
    "registration_endpoint":"https://dev-38997354.okta.com/oauth2/v1/clients",
    "jwks_uri":"https://dev-38997354.okta.com/oauth2/v1/keys",
    "response_types_supported":[
        "code",
        "id_token",
        "code id_token",
        "code token",
        "id_token token",
        "code id_token token"
    ],
    "response_modes_supported":[
        "query",
        "fragment",
        "form_post",
        "okta_post_message"
    ],
    "grant_types_supported":[
        "authorization_code",
        "implicit",
        "refresh_token",
        "password"
    ],
    "subject_types_supported":[
        "public"
    ],
    "id_token_signing_alg_values_supported":[
        "RS256"
    ],
    "scopes_supported":[
        "openid",
        "email",
        "profile",
        "address",
        "phone",
        "offline_access",
        "groups"
    ],
    "token_endpoint_auth_methods_supported":[
        "client_secret_basic",
        "client_secret_post",
        "client_secret_jwt",
        "private_key_jwt",
        "none"
    ],
    "claims_supported":[
        "iss",
        "ver",
        "sub",
        "aud",
        "iat",
        "exp",
        "jti",
        "auth_time",
        "amr",
        "idp",
        "nonce",
        "name",
        "nickname",
        "preferred_username",
        "given_name",
        "middle_name",
        "family_name",
        "email",
        "email_verified",
        "profile",
        "zoneinfo",
        "locale",
        "address",
        "phone_number",
        "picture",
        "website",
        "gender",
        "birthdate",
        "updated_at",
        "at_hash",
        "c_hash"
    ],
    "code_challenge_methods_supported":[
        "S256"
    ],
    "introspection_endpoint":"https://dev-38997354.okta.com/oauth2/v1/introspect",
    "introspection_endpoint_auth_methods_supported":[
        "client_secret_basic",
        "client_secret_post",
        "client_secret_jwt",
        "private_key_jwt",
        "none"
    ],
    "revocation_endpoint":"https://dev-38997354.okta.com/oauth2/v1/revoke",
    "revocation_endpoint_auth_methods_supported":[
        "client_secret_basic",
        "client_secret_post",
        "client_secret_jwt",
        "private_key_jwt",
        "none"
    ],
    "end_session_endpoint":"https://dev-38997354.okta.com/oauth2/v1/logout",
    "request_parameter_supported":true,
    "request_object_signing_alg_values_supported":[
        "HS256",
        "HS384",
        "HS512",
        "RS256",
        "RS384",
        "RS512",
        "ES256",
        "ES384",
        "ES512"
    ]
}

参考文档

  1. OIDC Discovery Spec: https://openid.net/specs/openid-connect-discovery-1_0.html
  2. Well-known URIs: https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml
  3. Google openid-configuration;
  4. Okta openid-configuration;
目录
相关文章
|
安全 Java 数据库
Security授权实现
Security授权实现
61 0
|
10月前
|
安全 Java 关系型数据库
Keycloak单点登录
Keycloak单点登录
198 0
|
云安全 安全 Java
STS (Security Token Service)
阿里云STS(Security Token Service)是一种云安全服务,用于为阿里云RAM用户(或其他云账号)颁发临时的安全令牌,以便在一定时间内访问阿里云资源,从而实现安全授权和身份验证的目的。
3755 0
|
安全 Java 数据库
Spring Security并结合JWT实现用户认证(Authentication) 和用户授权(Authorization)
在Web应用开发中,安全一直是非常重要的一个方面。Spring Security基于Spring 框架,提供了一套Web应用安全性的完整解决方案。
572 0
|
缓存 安全 算法
用户认证(Authentication)进化之路:由Basic Auth到Oauth2再到jwt
用户认证是一个在web开发中亘古不变的话题,因为无论是什么系统,什么架构,什么平台,安全性是一个永远也绕不开的问题 在HTTP中,基本认证(Basic access authentication)是一种用来允许网页浏览器或其他客户端程序在请求时提供用户名和口令形式的身份凭证的一种登录验证方式。
用户认证(Authentication)进化之路:由Basic Auth到Oauth2再到jwt
Basic Auth认证
Basic Auth认证
163 1
|
jenkins 持续交付 数据安全/隐私保护
『Jenkins』Jenkins实现权限控制——Role-based Authorization Strategy
📣读完这篇文章里你能收获到 - 本文将以图文的形式带你一步一步配置Jenkins角色权限 - 你将了解到角色权限的概念及账号的管理
313 0
『Jenkins』Jenkins实现权限控制——Role-based Authorization Strategy
|
NoSQL 安全 Java
【SpringCloud-Alibaba系列教程】13.gateway网关结合Sa-token进行登录鉴权
本文是对网关内容的拓展,进行鉴权部分的实现。
1616 0
【SpringCloud-Alibaba系列教程】13.gateway网关结合Sa-token进行登录鉴权
|
存储 安全 前端开发
OIDC SSO - OAuth2.0的授权模式选择
## 背景信息 > OIDC SSO相关文档总共4篇,主要内容为对OIDC实现SSO登录流程时的各个细节和相关技术的阐述:1. 《OIDC SSO - OAuth2.0的授权模式选择》 2. 《[OIDC SSO - 相关SSO流程和注意事项](https://ata.alibaba-inc.com/articles/218495)》 3. 《[OIDC SSO - Discovery Mech
1064 0
OIDC SSO - OAuth2.0的授权模式选择
|
JavaScript API Perl
关于SAP Commerce Cloud CORS policy的设置问题
关于SAP Commerce Cloud CORS policy的设置问题
146 0
关于SAP Commerce Cloud CORS policy的设置问题