gpt4 book ai didi

java - Spring Boot Security 中 OAuth2Client 中的 SSO

转载 作者:行者123 更新时间:2023-11-30 05:42:11 25 4
gpt4 key购买 nike

我一直在阅读有关 Spring Security 中的 OAuth2 集成以及如何通过第三方身份提供商(例如 Google)实现身份验证/授权的内容。

我使用 @EnableOauth2Sso 注释实现了 SSO 登录,并将以下内容添加到我的 application.properties 中:

security:
oauth2:
client:
clientId: 8d...f5e
clientSecret: 2d...1b
accessTokenUri: https://sso.domain.com/oauth/token
userAuthorizationUri: https://sso.domain.com/oauth/authorize
scope: openid
resource:
userInfoUri: https://sso.domain.com/userinfo

这看起来太神奇了,我不知道幕后发生了什么。按照 Spring 官方网站上的指南 Manual Configuration of OAuth2 Client我看到它切换到 @EnableOauth2Client 而不是 @EnableOauth2Sso 并且它说:

First off we can inject an OAuth2ClientContext and use it to build an authentication filter that we add to our security configuration

什么是OAuth2ClientContext?我查了官方API Docs它只是说它是一个接口(interface),但仍然不确定它到底是什么以及如何使用。

我遗漏了什么或者官方文档不够吗?我仍然无法掌握 OAuth2ClientContext、OAuth2ClientAuthenticationProcessingFilter 和 OAuth2RestTemplate 如何协同工作通过 SSO 在 Spring 中执行身份验证。

请指出文档的任何正确部分,以掌握基础知识。提前致谢。

最佳答案

这是一个准备运行的 example 。它根据授权服务器对客户端进行身份验证,还从资源服务器访问 protected 资源。

我仍在努力记录源代码并完成自述文件。如果您有疑问,请随时问我。

关于java - Spring Boot Security 中 OAuth2Client 中的 SSO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55442134/

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