为什么zuul代理不中继oauth2令牌?

时间:2019-03-08 11:33:41

标签: spring-boot spring-security oauth-2.0 netflix-zuul

我有网关支持的zuul代理,并提供代理服务。 当我尝试通过网关请求服务时,我收到401。Zuul不中继令牌。

Zuul和OAuth2配置

@Configuration
@EnableOAuth2Sso
@EnableZuulProxy
public class LogInConfig extends WebSecurityConfigurerAdapter {

@Bean
public OAuth2RestOperations restOperations(OAuth2ProtectedResourceDetails resource, OAuth2ClientContext context){
        return new OAuth2RestTemplate(resource, context);
    }

}

我的依赖项:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-cloud-connectors'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-ribbon'
    implementation 'org.springframework.cloud:spring-cloud-starter-oauth2'
    implementation 'org.springframework.cloud:spring-cloud-starter-security'
    implementation 'org.springframework.session:spring-session-core'
    implementation 'javax.xml.bind:jaxb-api'
    implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0.1'
    implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0.1'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'com.h2database:h2'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
}

如您所见,添加了spring-cloud-starter-security。

0 个答案:

没有答案