如何解决Google作为授权服务器
我正在提供一些Spring安全性细节以支持OIDC,并尝试以GOOGLE作为OpenID Provider来实现授权代码流,我有一些疑问:
- 在OIDC流中,可以将GOOGLE OpenID Provider用作授权服务器吗?如果不能,那么您可以提供一些公共授权服务器的列表(特别是同时支持OpaqueToken和JWT的服务器)。
- 我的配置有什么问题-不幸的是,当我尝试使用该访问令牌从资源中获取数据时,我现在可以对用户进行身份验证(从GOOGLE获取访问令牌和ID令牌以及所有请求的个人资料详细信息)服务器响应为401。
客户端-具有以下配置的Spring Boot应用程序:
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.httpBasic().disable()
.logout().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
.and()
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/**").authenticated()
.anyRequest().denyAll()
.and()
.oauth2Login()
;
}
客户端的应用程序属性文件:
spring:
security:
oauth2:
client:
registration:
my-oidc:
client-id: XXX.apps.googleusercontent.com
client-secret: XXX
authorization-grant-type: authorization_code
redirect-uri: "http://localhost:8083/login/oauth2/code/redirecturi"
scope: openid,profile
provider:
my-oidc:
authorization-uri: https://accounts.google.com/o/oauth2/v2/auth
token-uri: https://oauth2.googleapis.com/token
jwk-set-uri: https://www.googleapis.com/oauth2/v3/certs
资源服务器-具有以下配置的Spring Boot应用程序:
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.formLogin().disable()
.httpBasic().disable()
.logout().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/**").authenticated()
.and()
.oauth2ResourceServer(OAuth2ResourceServerConfigurer::opaqueToken)
;
}
资源服务器的应用程序属性文件:
spring:
security:
oauth2:
resourceserver:
opaquetoken:
client-id: XXX.apps.googleusercontent.com
client-secret: XXX
introspection-uri: "https://accounts.google.com/o/oauth2/v2/auth"
授权服务器-当前正在尝试使用google OpenID Connect
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。