java - Spring Boot 中的 OAuth2 - 云
问题描述
我想创建支持 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>
应用程序.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 调用可能会被负载均衡器重定向到每个实例。
我做了一个简单的测试:
- 开始申请
- 调用应用程序 api
- 重定向到 oidc 登录页面以提供凭据
- 重新启动的应用程序(新的、不同的应用程序实例)
- 提交的凭据
- 重定向回应用程序,得到“ authorization_request_not_found ”错误
是否可以设置 oauth 以使其更耐在云中用作多实例应用程序?感谢一百万的任何建议!
解决方案
推荐阅读
- json - 如何在 jq 中传播对象的属性?
- javascript - 如何在 Vue 组件中使用 JavaScript
- mysql - 如何在过程中的 If 内执行多个查询?
- javascript - 如何遍历它并检查skip是否接受数字,如果不是打印错误
- excel - 将 With-function 中的内部颜色应用到一定范围内
- apache-flink - Apache Flink - FsStateBackend - 在任务管理器失败的情况下如何恢复状态,将状态存储在其本地文件系统中
- swift - Swift 可重用 NavigationLink
- c# - Web api Restful : 通过外键获取资源
- python - 运行 sls deploy 时无服务器挂起。Docker 命令没有结束
- git - 有没有办法 gitignore 所有当前的额外文件?