【问题标题】:How can i configure oauth2 resourceserver for spring webflux app?如何为 spring webflux 应用程序配置 oauth2 资源服务器?
【发布时间】:2019-02-27 20:45:36
【问题描述】:

Spring security 5.1.0.Rc1 支持 webflux 中的 OAuth2 资源服务器 - https://spring.io/blog/2018/08/21/spring-security-5-1-0-rc1-released

此处给出的示例讨论了基于 JWT 格式的 Oauth2。 如何配置基于 oauth2 资源服务器并指定令牌解码 uri。

在春季 MVC 中,我可以使用 @EnableResourceServer 和 security.oauth2.resource.token-info-uri 属性。我将如何使用 webflux 做同样的事情?

【问题讨论】:

    标签: spring-security spring-security-oauth2 spring-webflux


    【解决方案1】:

    我不知道它是否真的适用于 RC1,但使用 2.1.0.M1 我可以让它像这样工作:

    build.gradle:

    repositories {
        mavenCentral()
        maven {
            url 'https://repo.spring.io/libs-snapshot'
        }
    }
    
    dependencyManagement {
        imports {
            mavenBom 'org.springframework.cloud:spring-cloud-gateway:2.1.0.M1'
        }
    }
    
    dependencies {
        compile 'org.springframework.boot:spring-boot-starter-security'
    
        compile 'org.springframework.security:spring-security-oauth2-jose'
        compile 'org.springframework.security:spring-security-oauth2-client'
        compile 'org.springframework.security:spring-security-oauth2-resource-server'
    }
    

    应用程序.yaml

    spring:
     security:
        oauth2:
          resourceserver:
            jwt:
              jwk-set-uri: http://keycloak.example.com/auth/realms/your-realm/protocol/openid-connect/certs
    

    https://github.com/spring-projects/spring-security/tree/master/samples/boot/oauth2resourceserver-webflux也有一个示例

    【讨论】:

      猜你喜欢
      • 2016-01-18
      • 2017-09-13
      • 2017-03-25
      • 2021-05-19
      • 2019-04-29
      • 2017-03-29
      • 2015-11-19
      • 2013-12-21
      • 2018-04-14
      相关资源
      最近更新 更多