我正在使用 Spring Security OAuth2(http://projects.spring.io/spring-security-oauth/docs/oauth2.html)开发资源服务器,它与授权服务器交互以检索/验证授权 token 。此处使用的 OAuth Flow 是“客户端凭据”。当资源服务器在授权服务器之后启动时,应用程序工作正常,但在资源服务器在授权服务器之前启动的情况下,所有客户端请求都会收到状态代码为 401 的“无效 token ”错误。
我可以考虑使用拦截器拦截使用 ClientHttpRequestInterceptor 的请求并具有重试逻辑。但是,当 Auth Server 短时间不可用时,是否有正确的方法来为 Resource Server 实现适当的弹性或恢复机制。
任何指示都会有所帮助。
最佳答案
有一个ResourceServerProperties issue默认过滤顺序已更改。试试这个 security.oauth2.resource.filter-order = 3
OAuth 2 Resource Filter The default order of the OAuth2 resource filter has changed from 3 to SecurityProperties.ACCESS_OVERRIDE_ORDER - 1. This places it after the actuator endpoints but before the basic authentication filter chain. The default can be restored by setting security.oauth2.resource.filter-order = 3
Release note of oauth-2-resource-filter
关于spring-security - Spring Security OAuth2 资源服务器重试/弹性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49186584/