参考的
OpenID Connect 1.0 是 OAuth 2.0 协议之上的简单身份层。它使客户端能够根据授权服务器执行的身份验证验证最终用户的身份,并以可互操作和类似 REST 的方式获取有关最终用户的基本配置文件信息。
该规范定义了 OpenID Connect 依赖方如何动态地向最终用户的 OpenID 提供者注册,向 OpenID 提供者提供有关自身的信息,并获取使用它所需的信息,包括此依赖方的 OAuth 2.0 客户端 ID。
客户端具有与其在授权服务器上的唯一客户端标识符相关联的元数据。这些范围可以从面向人的显示字符串(例如客户端名称)到影响协议安全性的项目(例如有效重定向 URI 列表)。
作为注册请求的输入值,以及
作为注册响应和读取响应中的输出值

为了在授权服务器上注册一个新的客户端,客户端向客户端注册端点发送一条 请求路径为 /connect/registe的HTTP POST消息,其中包含客户端在注册期间选择为自己指定的任何客户端元数据参数。授权服务器为这个客户端分配一个唯一的客户端标识符,可选地分配一个客户端秘密,并将请求中给出的元数据与发出的客户端标识符相关联。授权服务器可以为客户端元数据中省略的任何项目提供默认值。就是授权服务器(OP)提供了一个资源接口,通过特定的scope的访问令牌来进行注册客户端的请求
POST /connect/register HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: server.example.com
Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJ
{
"application_type": "web",
"redirect_uris":
["https://client.example.org/callback",
"https://client.example.org/callback2"],
"client_name": "My Example",
"logo_uri": "https://client.example.org/logo.png",
"subject_type": "pairwise",
"sector_identifier_uri":
"https://other.example.net/file_of_redirect_uris.json",
"token_endpoint_auth_method": "client_secret_basic",
"jwks_uri": "https://client.example.org/my_public_keys.jwks",
"userinfo_encrypted_response_alg": "RSA1_5",
"userinfo_encrypted_response_enc": "A128CBC-HS256",
"contacts": ["ve7jtb@example.org", "mary@example.org"],
"request_uris":
["https://client.example.org/rf.txt
#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA"]
}
成功注册后,客户端注册端点返回新创建的客户端标识符和(如果适用)客户端密码,以及有关此客户端的所有已注册元数据,包括授权服务器本身提供的任何字段。授权服务器可以拒绝或替换任何客户端请求的字段值,并用合适的值替换它们。如果发生这种情况,授权服务器必须在对客户端的响应中包含这些字段。授权服务器可以忽略客户端提供的值,并且必须忽略客户端发送的任何它不理解的字段。
HTTP/1.1 201 创建
内容类型:应用程序/json
缓存控制:无存储
Pragma:无缓存
{
"client_id": "s6BhdRkqt3",
“client_secret”:
"ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk",
“client_secret_expires_at”:1577858400,
“registration_access_token”:
"this.is.an.access.token.value.ffx83",
“registration_client_uri”:
"https://server.example.com/connect/register?client_id=s6BhdRkqt3",
“token_endpoint_auth_method”:
"client_secret_basic",
“应用程序类型”:“网络”,
“redirect_uris”:
["https://client.example.org/callback",
"https://client.example.org/callback2"],
"client_name": "我的例子",
“client_name#ja-Jpan-JP”:
“客户名称”,
"logo_uri": "https://client.example.org/logo.png",
“subject_type”:“成对”,
“sector_identifier_uri”:
"https://other.example.net/file_of_redirect_uris.json",
"jwks_uri": "https://client.example.org/my_public_keys.jwks",
“userinfo_encrypted_response_alg”:“RSA1_5”,
"userinfo_encrypted_response_enc": "A128CBC-HS256",
“联系人”:[“ve7jtb@example.org”,“mary@example.org”],
“request_uris”:
["https://client.example.org/rf.txt
#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA”]
}
如果客户端的初始注册返回了客户端配置端点和注册访问令牌,则可以通过使用注册访问令牌向客户端配置端点发出 HTTP GET请求来 读取授权服务器上客户端的当前配置。
GET /connect/register?client_id=s6BhdRkqt3 HTTP/1.1
Accept: application/json
Host: server.example.com
Authorization: Bearer this.is.an.access.token.value.ffx83
OIDC定义了有限对外开放的客户端注册端点,这个端点在做开放平台的时候非常有用。

OAuth2AuthorizationServerConfigurer<HttpSecurity> authorizationServerConfigurer =
new OAuth2AuthorizationServerConfigurer<>();
authorizationServerConfigurer.oidc(oidcConfigurer ->
oidcConfigurer.clientRegistrationEndpoint(Customizer.withDefaults()));

OidcClientRegistrationEndpointFilter 拦截的请求为/connect/register

OidcClientRegistrationAuthenticationToken交给OidcClientRegistrationAuthenticationProvider后,首先提取access_token,查询校验access_token。
然后查看OidcClientRegistrationAuthenticationToken是否封装了OidcClientRegistration,如果封装了就是新增或者更新;没有就是查询。

使用 HTTP GET请求来查询 OpenID 提供者配置文档。
OP 将向 Issuer https://example.com发出以下请求以 获取其配置信息,因为 Issuer 不包含路径组件
GET /.well-known/openid-configuration HTTP/1.1
Host: example.com
响应是一组关于 OpenID 提供者配置的声明,包括所有必要的端点和公钥位置信息。
提供者响应数的数据是有该过滤器处理的
