gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 16:35:53 27 4
gpt4 key购买 nike

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

我想避免将有关授权服务器地址的信息硬编码到客户端软件中。相反,我希望资源服务器提供指向 auth 服务器的提供者发现端点的链接,这可能是 HTTP 401 挑战的一部分。我可以发明一个 X-MyApp-* header ,但我想知道是否有针对此的既定约定(无论是 HTTP header 、401 响应中的正文内容、资源服务器上的标准 URL 等)?

最佳答案

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

Section 3规范的定义如下,

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

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

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

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

WWW-Authenticate: Bearer realm="example", auth_server="URL-TO-OIDC-SERVER"

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

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com