【发布时间】:2019-01-09 16:50:58
【问题描述】:
我的问题是使用 Oauth2 的 Cloudgateway 安全性。但是Oauth2的配置@EnableOAuth2Sso会导致如下错误:
说明:
org.springframework.cloud.gateway.config.GatewayAutoConfiguration 中方法 modifyRequestBodyGatewayFilterFactory 的参数 0 需要一个找不到的 'org.springframework.http.codec.ServerCodecConfigurer' 类型的 bean。
行动:
考虑在你的配置中定义一个“org.springframework.http.codec.ServerCodecConfigurer”类型的bean。
当我在 Eureka 上对 Zuul 代理执行相同操作时,一切正常。 请帮我解决这个问题。
这是 Cloudgateway 项目,我正在尝试使其成为 Oauth2 客户端:
配置:
@Configuration
@EnableOAuth2Sso
public class UiSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/login**")
.permitAll()
.anyRequest()
.authenticated();
}
}
application.yml:
server:
port: 8080
servlet:
session:
cookie:
name: UISESSION
security:
oauth2:
client:
clientId: SampleClientId
clientSecret: secret
accessTokenUri: http://localhost:8085/auth/oauth/token
userAuthorizationUri: http://localhost:8085/auth/oauth/authorize
resource:
userInfoUri: http://localhost:8085/auth/principal
spring:
application:
name: gateway
cloud:
gateway:
discovery:
locator:
enabled: false
routes:
- id: microservice1WelcomeRoute
uri: http://localhost:8083/view/welcome
predicates:
- Path=/microservice1/welcome
我正在使用授权码模式的Oauth2服务器,参考这个question:
【问题讨论】:
-
您可能想了解stackoverflow.com/questions/49795385/… 和相关问题
标签: java spring-boot oauth-2.0 spring-security-oauth2 spring-cloud-gateway