OIDC SSO - Discovery Mechanism

在线体验各类最新模型,更有模型 免费Token 额度领取!
立即体验
简介: ## 背景信息> 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;
目录
相关文章
|
jenkins Java Shell
使用 Docker 安装 Jenkins 并实现项目自动化部署
Jenkins 是一款开源的持续集成(DI)工具,广泛用于项目开发,能提供自动构建,测试,部署等功能。作为领先的开源自动化服务器,Jenkins 提供了数百个插件来支持构建、部署和自动化任何项目。
37154 3
使用 Docker 安装 Jenkins 并实现项目自动化部署
|
JSON Dubbo 测试技术
逐步教你如何在Postman中导入Swagger API
在现代软件开发中,Swagger 和 Postman 作为 API 设计、开发和测试的利器,都被广泛应用。可以将 Swagger 定义的 API 导入到 Postman 中,充分利用 Postman 强大的测试特性对接口进行深入测试。
vite环境引入web worker方法
在 vite 环境中使用 web worker 时,如果遇到生产环境中 worker.js 文件的 MIME 类型被识别为 text/html,导致报错无法运行的情况时,可以参考以下两种方法,原理都是避免编译时产出单独的 worker.js 文件。方法一worker文件不需要包装,引入时后缀增加 ?worker&inline,使用时直接 new ImportedWorker();self.
2002 1
|
关系型数据库 MySQL 索引
MySQL数据表添加字段的三种方式
MySQL数据表添加字段的三种方式
9901 0
|
机器学习/深度学习 JSON 监控
国内最大的MCP中文社区来了,4000多个服务等你体验
国内最大的MCP中文社区MCPServers来了!平台汇聚4000多个服务资源,涵盖娱乐、监控、云平台等多个领域,为开发者提供一站式技术支持。不仅有丰富的中文学习资料,还有详细的实战教程,如一键接入MCP天气服务等。MCPServers专注模块稳定性和实用性,经过99.99% SLA认证,是高效开发的理想选择。立即访问mcpservers.cn,开启你的开发之旅!
15281 16
|
7月前
|
存储 缓存 人工智能
图索引性能提升 400%:详解 VSAG 向量检索框架
VSAG 是蚂蚁集团开源的图索引向量检索框架。 本文源自 VSAG 团队在 VLDB'25 发表的《VSAG: An Optimized Search Framework for Graph-based Approximate Nearest Neighbor Search》,介绍 VSAG 框架如何通过缓存优化、自动调参和距离计算加速,在保证高召回率前提下将检索性能提升最高 400%。
|
存储 NoSQL Redis
docker搭建Redis Cluster集群环境
docker搭建Redis Cluster集群环境
751 1
|
应用服务中间件 nginx Docker
使用 Python Flask 创建简易文件上传服务
在平时工作中,文件上传是一项常见的需求,例如将应用异常时通过脚本生成的dump文件收集起来进行分析,但实现起来却可能相当复杂。幸运的是,Flask框架提供了一种简单而高效的方式来处理文件上传,代码不到100行。在本文中,我们将探讨如何使用Flask实现文件上传功能,编写Dockerfile将应用程序通过docker部署。
|
12月前
|
安全 Linux 网络安全
ssh-server配置文件参数PermitRootLogin介绍
**PermitRootLogin** 是 SSH 服务(sshd)配置文件 /etc/ssh/sshd_config 中的一个参数,用于控制是否允许通过 SSH 直接以 root 用户身份 登录到服务器。这个设置是为了增强系统的安全性,特别是在远程访问和管理服务器时。
2440 0
|
XML 前端开发 Java
【Spring MVC 系列】Spring MVC 中 Filter 配置的 6 种方式,看看你了解哪些
Filter 简介 过滤器 Filter 在 Servlet 2.3 版本中被首次提出,唯一的作用就是过滤,它不仅可以过滤请求,还可以过滤响应,当请求到达 Servlet 容器,会先经过 Filter ,然后再交给 Servlet,之后 Filter 还可以对 Servlet 的响应进一步处理。并且多个 Filter 还能形成一个链。使用图示表达如下。
1782 0
【Spring MVC 系列】Spring MVC 中 Filter 配置的 6 种方式,看看你了解哪些