spring-attic / spring-cloud-security

Security concerns for distributed applications implemented in Spring
Apache License 2.0
532 stars 244 forks source link

feign has conflict with @EnableWebFluxSecurity #226

Closed xinghen110 closed 4 years ago

xinghen110 commented 4 years ago

Summary Authorization spring-cloud-gateway with spring-security(use @EnableWebFluxSecurity), and provid userInfoService by a microservice through http (by feign). It cause a cycle dependencies exception:

Description:

The dependencies of some of the beans in the application context form a cycle:

webSecurityConfig defined in file [C:\Users\hexin\IdeaProjects\springcloud\gateway\target\classes\com\demo\microservice\gateway\config\WebSecurityConfig.class]
┌─────┐
| userDetailsServiceImpl defined in file [C:\Users\hexin\IdeaProjects\springcloud\gateway\target\classes\com\demo\microservice\gateway\service\UserDetailsServiceImpl.class]
↑ ↓
| IUserService defined in file [C:\Users\hexin\IdeaProjects\springcloud\common\common-interface\target\classes\com\microservice\common\service\impl\UserServiceImpl.class]
↑ ↓
| com.microservice.common.provider.UserServiceProvider =======(**here, i use feign to call another microservice, it cause the exception!!!**) =============
↑ ↓
| org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$EnableWebFluxConfiguration
↑ ↓
| org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration (field private org.springframework.security.core.userdetails.ReactiveUserDetailsService org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration.reactiveUserDetailsService)
└─────┘

Version spring-cloud-starter-security 2.1.5 spring-cloud-starter-openfeign 2.1.4 spring-boot 2.1.10 spring-cloud Greenwich.SR4 spring-cloud-alibaba 2.1.1

spencergibb commented 4 years ago

Have you tried using ObjectProvider<MyFeignClient> in UserServiceProvider?

xinghen110 commented 4 years ago

It works, think you!