客户端应用程序应该如何处理通过 OpenID Connect 获得的 JWT?
What is the client app supposed to do with the JWT obtained via OpenID Connect?
我有一个 OIDC 似乎很适合的场景:用户需要从服务器获取一些私人数据的移动应用程序。我已经阅读了 OIDC 教程 such as this one,我想我已经理解了它们,但是在全局视图中还有一个关键的最终 "hole"。
无论如何,如果我正确理解了 OIDC 的代码流,这是对交互的简要总结:
- 移动应用程序将联系 OIP 授权端点,在
scope
中表明我们对用户的电子邮件感兴趣。它将作为 redirect_uri
指向移动应用程序本身中的简单 Web 服务器 运行 的指针。
- OIP 将通过
redirect_uri
联系移动应用程序,并为其提供授权码。
- 移动应用现在将联系 OIP 令牌端点并向其提供在步骤 2 中获得的授权代码。它还将向 OIP 提供
redirect_uri
必须发送回复的位置。
- OIP 将通过
redirect_uri
联系该应用,并向其提供带有我们要求的声明(电子邮件)的签名 JWT。
教程到此结束。我假设现在暗示移动应用程序会将在步骤 4 中获得的 JWT 发送到我的服务器。但是,服务器应该如何知道 JWT 是有效的呢?当然,它是由 OIP 签名的,但是服务器是否应该有一个硬编码的 OIP public 密钥列表来验证 JWT?我发现的 OIDC 教程中似乎缺少最后这些关键步骤...
OpenID Authorization Code flow] 在第 4 点略有不同。一旦获得授权令牌,客户端就向令牌端点请求令牌 ID,其中 returns 包含的响应一个 ID Token,没有重定向(请求必须包含 redirect_uri
参数,服务器将确保与原始的相同)
这是完整的OpenID Authorization code flow
- Client prepares an Authentication Request containing the desired
request parameters.
- Client sends the request to the Authorization
Server.
- Authorization Server Authenticates the End-User.
- Authorization Server obtains End-User Consent/Authorization.
- Authorization Server sends the End-User back to the Client with an Authorization Code.
- Client requests a response using the Authorization Code at the Token Endpoint.
- Client receives a response that contains an ID Token and Access Token in the response body.
- Client validates the ID token and retrieves the End-User's Subject Identifier.
最后客户端必须根据3.1.3.4 ID Token Validation验证令牌。重点总结如下:
iss
包含发行者标识符和 aud
您的 client_id
当前时间 iat
和 exp
使用发行人提供的密钥验证令牌的签名。在此流程中,TLS 服务器验证可用于验证颁发者,而不是检查令牌签名。在 HMAC 的情况下,client_secret
of client_id 用作验证
的密钥
验证请求 nonce
、azp
或 azr
我有一个 OIDC 似乎很适合的场景:用户需要从服务器获取一些私人数据的移动应用程序。我已经阅读了 OIDC 教程 such as this one,我想我已经理解了它们,但是在全局视图中还有一个关键的最终 "hole"。
无论如何,如果我正确理解了 OIDC 的代码流,这是对交互的简要总结:
- 移动应用程序将联系 OIP 授权端点,在
scope
中表明我们对用户的电子邮件感兴趣。它将作为redirect_uri
指向移动应用程序本身中的简单 Web 服务器 运行 的指针。 - OIP 将通过
redirect_uri
联系移动应用程序,并为其提供授权码。 - 移动应用现在将联系 OIP 令牌端点并向其提供在步骤 2 中获得的授权代码。它还将向 OIP 提供
redirect_uri
必须发送回复的位置。 - OIP 将通过
redirect_uri
联系该应用,并向其提供带有我们要求的声明(电子邮件)的签名 JWT。
教程到此结束。我假设现在暗示移动应用程序会将在步骤 4 中获得的 JWT 发送到我的服务器。但是,服务器应该如何知道 JWT 是有效的呢?当然,它是由 OIP 签名的,但是服务器是否应该有一个硬编码的 OIP public 密钥列表来验证 JWT?我发现的 OIDC 教程中似乎缺少最后这些关键步骤...
OpenID Authorization Code flow] 在第 4 点略有不同。一旦获得授权令牌,客户端就向令牌端点请求令牌 ID,其中 returns 包含的响应一个 ID Token,没有重定向(请求必须包含 redirect_uri
参数,服务器将确保与原始的相同)
这是完整的OpenID Authorization code flow
- Client prepares an Authentication Request containing the desired request parameters.
- Client sends the request to the Authorization Server.
- Authorization Server Authenticates the End-User.
- Authorization Server obtains End-User Consent/Authorization.
- Authorization Server sends the End-User back to the Client with an Authorization Code.
- Client requests a response using the Authorization Code at the Token Endpoint.
- Client receives a response that contains an ID Token and Access Token in the response body.
- Client validates the ID token and retrieves the End-User's Subject Identifier.
最后客户端必须根据3.1.3.4 ID Token Validation验证令牌。重点总结如下:
iss
包含发行者标识符和aud
您的client_id
当前时间
iat
和exp
使用发行人提供的密钥验证令牌的签名。在此流程中,TLS 服务器验证可用于验证颁发者,而不是检查令牌签名。在 HMAC 的情况下,
client_secret
of client_id 用作验证 的密钥
验证请求
nonce
、azp
或azr