我想创建支持 oauth2/oidc 的 spring 云网关。已经创建了示例项目,并添加了 spring-boot-starter-oauth2-client 和 spring-boot-starter-web 依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
application.yml:
spring:
security:
oauth2:
client:
registration:
my-provider:
authorization-grant-type: authorization_code
redirect-uri: https://localhost:9443/login/oauth2/code/callback
scope:
- openid
client-id: xxxxxx
client-secret: xxxxxx
provider:
my-provider:
authorization-uri: xxxxxx
token-uri: xxxxxx
jwk-set-uri: xxxxxx
我的问题是我想在云环境中运行这个应用程序,所以考虑到应用程序的许多实例,而且 api 调用可能会被负载均衡器重定向到每个实例。
我做了一个简单的测试:
是否可以设置 oauth 以使其更适合在云中用作多实例应用程序? 感谢一百万的任何建议!