Spring Security-OAuth2-网关-Google Provider

问题描述

我一直在尝试使用以下示例使用Gateway + Oauth: https://spring.io/blog/2019/08/16/securing-services-with-spring-cloud-gateway 只是不使用本示例中的UAA服务器,而是使用了开箱即用的Google Provider并查看了以下内容https://docs.spring.io/spring-cloud-security/docs/2.2.4.RELEASE/reference/html/#_client_token_relay_in_spring_cloud_gateway配置资源服务器。 像示例中一样,我有一个在类路径上具有安全性的网关。我已经通过application.yaml(在Google Api网关注册后获得的clientID和secrect)将Google注册为提供程序,并在端口8080上监听

使用以下设置在类路径上的资源服务器上侦听端口8888的另一项服务:

spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          jwk-set-uri: https://www.googleapis.com/oauth2/v3/certs

我从Google发现网址https://accounts.google.com/.well-known/openid-configuration中获得的网址

我有一个基本的angular应用程序示例,该应用程序显示登录页面并具有google登录链接。 这部分的行为符合预期,将我带到google登录,然后重定向回spring应用程序,网关上的一切似乎都很好,但是我在资源服务器中抛出了令牌错误

An error occurred while attempting to decode the Jwt: Invalid unsecured/JWS/JWE header: Invalid JSON: Unexpected token ɭ� at position 2.
at org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider.authenticate(JwtAuthenticationProvider.java:86) ~[spring-security-oauth2-resource-server-5.3.4.RELEASE.jar:5.3.4.RELEASE]

首先想到的可能是错误的或未正确设置,例如:JWT编码器/解码器 在Google测试网址上手动触发令牌:https://oauth2.googleapis.com/tokeninfo?id_token=XYZ123 记录在https://developers.google.com/identity/protocols/oauth2/openid-connect

底部

返回:

{
  "error": "invalid_token","error_description": "Invalid Value"
}

检查了签发时间和到期时间,看来签发时间准确显示为=当前小时-1,而签发时间=当前时间

我不确定这是怎么回事?

如果有人对这里发生的事情有任何线索并可以答复,将不胜感激。

谢谢..

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)