We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
是否不登陆也可以直接访问/oauth2/authorize,然后获取code,再获取token
The text was updated successfully, but these errors were encountered:
这个问题的关键在于, oauth2.1(OAuth2AuthorizationServer)是如何获取当前登录用户信息的?
SpringSecurity 通过session会话, 将当前登录用户的信息设置到 SecurityContext中.
流程: 在登录成功之后, 进行的是用户 手动授权或者自动授权 自己的信息给到第三方.
本项目使用的是 自动授权. 也可以在登录成功的授权页面中添加按钮等操作, 用户同意之后, 再次拿着临时code进行获取accesstoken.
/oauth2/authorize 对应的 OAuth2AuthorizationEndpointFilter 过滤器.
OAuth2AuthorizationEndpointFilter
1.需要将 路径中的参数进行转换,并获取当前登录用户的信息形成 OAuth2AuthorizationConsentAuthenticationToken, 此动作在 OAuth2AuthorizationConsentAuthenticationConverter中实现, 源码中 通过 SecurityContextHolder.getContext().getAuthentication();获取当前登录用户信息.
OAuth2AuthorizationConsentAuthenticationToken
OAuth2AuthorizationConsentAuthenticationConverter
SecurityContextHolder.getContext().getAuthentication();
也就意味着OAuth2AuthorizationServer是通过 当前session会话 获取当前登录用户信息的.
2.AuthenticationManager 进行验证.
在本项目中的关键配置:
Sorry, something went wrong.
No branches or pull requests
/auth/login登录接口与/oauth2/authorize认证接口没有明显的关联关系
是否不登陆也可以直接访问/oauth2/authorize,然后获取code,再获取token
The text was updated successfully, but these errors were encountered: