我正在尝试集成一个Spring Cloud Gateway (带有WebFlux)和Amazon AWS Cognito。我花了将近一周的时间,它仍然不起作用。我想要使用authorization_code授权类型来验证认知用户池中的用户。
以下是我的设置:
spring:
security:
oauth2:
client:
registration:
cognito:
client-id: xxxxx
client-secret: xxxx
scope: openid
redirectUriTemplate: "http://localhost:9090/login/oauth2/code/cognito"
clientName: xxxx-client
provider:
cognito:
issuerUri: https://cognito-idp.us-east-2.amazonaws.com/xxxxxxxxx
usernameAttribute: cognito:username这是我的pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-security</artifactId>
</dependency>我面临的一个问题是:
{"code":"BadRequest","message":"The server did not understand the operation that was requested.","type":"client"}和其他一些随机问题。我永远看不到Cognito的登录屏幕。如果你能提供一些示例应用程序,这将是有帮助的。
发布于 2020-08-27 07:03:05
问题是你需要为它设置一个域名。您可以在亚马逊网络服务的用户池->应用程序集成->域名页面下执行此操作。然后,您需要设置一个Amazon Cognito域。这个域名可以是任何名字,只要它不被使用。
希望这对某些人有帮助,因为这花了我几个小时的时间,我在任何地方都找不到答案。
https://stackoverflow.com/questions/60593382
复制相似问题