【问题标题】:Spring Security OAuth2 Resource Server retry/resilienceSpring Security OAuth2 资源服务器重试/弹性
【发布时间】:2018-08-17 14:26:26
【问题描述】:

我正在使用 Spring Security OAuth2(http://projects.spring.io/spring-security-oauth/docs/oauth2.html) 开发资源服务器,它与授权服务器交互以检索/验证身份验证令牌。此处使用的 OAuth 流程是“客户端凭据”。当资源服务器在授权服务器之后启动时,应用程序工作正常,但在资源服务器在授权服务器之前启动的情况下,所有客户端请求都会收到状态码 401 的“无效令牌”错误。

我可以考虑使用拦截器来拦截使用 ClientHttpRequestInterceptor 的请求并具有重试逻辑。但是当 Auth Server 短时间内不可用时,是否有正确的方法来为 Resource Server 实现适当的弹性或恢复机制

任何指针都会有所帮助。

【问题讨论】:

    标签: spring-security oauth-2.0 spring-security-oauth2 spring-oauth2


    【解决方案1】:

    ResourceServerProperties issue 更改了默认过滤顺序。试试这个security.oauth2.resource.filter-order = 3

    OAuth 2 资源过滤器 OAuth2 资源过滤器的默认顺序已从 3 更改为 SecurityProperties.ACCESS_OVERRIDE_ORDER - 1。这将其放置在执行器端点之后,但在基本身份验证过滤器链之前。可以通过设置 security.oauth2.resource.filter-order = 3 恢复默认值

    Release note of oauth-2-resource-filter

    【讨论】:

    • 感谢您的回复。我分别使用资源和身份验证服务器。您能否阐明过滤顺序在我的场景中的重要性(当 OAuth2 服务器短时间内不可用时尝试获取验证器密钥)
    猜你喜欢
    • 2019-11-27
    • 2013-12-21
    • 2015-06-13
    • 2017-03-25
    • 2017-12-15
    • 2018-07-08
    • 2021-10-29
    • 2020-10-28
    • 2018-07-15
    相关资源
    最近更新 更多