http - 用于指示 OpenID Connect 服务器位置的标准 HTTP header ?

标签 http oauth-2.0 openid-connect

我们正在开发一个 native 应用程序,用于访问资源服务器(也在我们的控制之下)上的内容。资源服务器将要求 native 应用程序的用户通过 OpenID Connect 进行身份验证,以获得作为不记名 token 传递的访问 key (RFC 6750)。授权服务器是运行Keycloak的独立服务器。

我想避免将有关授权服务器地址的信息硬编码到客户端软件中。相反,我希望资源服务器提供到身份验证服务器的提供程序发现端点的链接,这可能作为 HTTP 401 质询的一部分。我可以发明一个 X-MyApp-* header ,但我想知道是否有一个既定的约定(是否是 HTTP header 、401 响应中的正文内容、资源服务器上的标准 URL 等)?

最佳答案

RFC6750 定义了 WWW-Authenticate Response Header 的用法。

Section 3规范定义如下,

If the protected resource request does not include authentication credentials or does not contain an access token that enables access to the protected resource, the resource server MUST include the HTTP "WWW-Authenticate" response

您可以利用此 header 来响应授权服务器的地址。规范允许具有规范定义之外的属性,

All challenges defined by this specification MUST use the auth-scheme value "Bearer". This scheme MUST be followed by one or more auth-param values. The auth-param attributes used or defined by this specification are as follows. Other auth-param attributes MAY be used as well.

现在,如果我们可以定义一个名为 auth_server 的自定义属性,那么我们可以将其添加到 401 响应的 WWW-Authenticate header 中,如下所示

WWW 身份验证:承载领域=“示例”,auth_server=“URL-TO-OIDC-SERVER”

您的客户端必须解析 header 并提取 auth_server 值。

关于http - 用于指示 OpenID Connect 服务器位置的标准 HTTP header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50921816/

相关文章:

java - 在java中解析http响应字节

java - 为什么我的 OAuth2 无法与 Spring Boot 一起使用?

Azure API 管理和后端 Web API

既然 Google 已弃用其 OpenID2 提供商,那么 OpenID Connect 授权又如何?

Azure AD B2C 检索 token 时出现错误 "permissions"

c# - ASP.NET Core OpenIdConnect 服务器数据保护 key 位置

http - HTTPS 页面上的 Magento HTTP Canonical 标签

ios - 错误域=NSURLErrorDomain 代码=-1000 "bad URL"

http - EC2-无响应http请求

ios - 使用 iOS 客户端 ID 时,Google API 无法进行身份验证