Google作为授权服务器

问题描述

我正在提供一些Spring安全性细节以支持OIDC,并尝试以GOOGLE作为OpenID Provider来实现授权代码流,我有一些疑问:

  1. 在OIDC流中,可以将GOOGLE OpenID Provider用作授权服务器吗?如果不能,那么您可以提供一些公共授权服务器的列表(特别是同时支持OpaqueToken和JWT的服务器)。
  2. 我的配置有什么问题-不幸的是,当我尝试使用该访问令牌从资源中获取数据时,我现在可以对用户进行身份验证(从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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...