gpt4 book ai didi

java - Spring OAuth2 隐式流重定向 url

转载 作者:行者123 更新时间:2023-12-02 15:14:52 24 4
gpt4 key购买 nike

在我的 Spring Boot/OAuth2 应用程序中,我试图通过我自己的 OAuth2 服务器使用以下 url 使用隐式流登录用户:

http://example.com/api/oauth/authorize?response_type=token&client_id=example_client_id&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Flogin

登录后,它将用户重定向到以下 url:

http://localhost:8080/login#access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoyOTcsInVzZXJfbmFtZSI6ImFkbWluIiwic2NvcGUiOlsicmVh&token_type=bearer&expires_in=43199&scope=read%20write&user_id=297&jti=9d416117-0d08-4f4e-874d-3f31dbe7815f

用户被重定向到带有 # 符号而不是 的 url 是正确的行为吗?.. 我的意思是:

http://localhost:8080/login?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoyOTcsInVzZXJfbmFtZSI6ImFkbWluIiwic2NvcGUiOlsicmVh&token_type=bearer&expires_in=43199&scope=read%20write&user_id=297&jti=9d416117-0d08-4f4e-874d-3f31dbe7815f

如果否 - 如何设置我的 Spring 应用程序 OAuth2 服务器以便将用户重定向到正确的 url?

最佳答案

行为是正确的。授权代码流要求将响应参数嵌入重定向 URI 的查询部分(RFC 6749,4.1.2. Authorization Response),而隐式流要求将响应参数嵌入片段 部分(RFC 6749,4.2.2. Access Token Response)。

OAuth 2.0 Multiple Response Type Encoding Practices 定义了一个新的请求参数,<strong>response_mode</strong> .该参数指定应嵌入响应参数的位置。在规范中,<strong>query</strong> , <strong>fragment</strong><strong>none</strong>被定义。此外, OAuth 2.0 Form Post Response Mode 添加了<strong>form_post</strong>作为 response_mode 的值.如果response_mode=form_post包含在授权请求中,响应参数作为 HTML 表单参数嵌入。

您可以找到一个描述 response_type 之间关系的表格/response_mode Authlete 的权威指南中的“2. Response Format”中的组合和 HTTP 状态/响应参数的位置。

enter image description here

关于java - Spring OAuth2 隐式流重定向 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41202384/

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