Spring-cloud-netflix: Hystrix shareSecurityContext is not working help me please

Created on 20 Apr 2018  路  5Comments  路  Source: spring-cloud/spring-cloud-netflix

the code is here
thanks

feedback-provided

Most helpful comment

@Comup-X
I think it's because of hystrix's default isolation strategy THREAD , using this Can never propagate ThreadLocal.

Maybe you should try to set isolation strategy of hystrix to SEMAPHORE,
reference: https://github.com/Netflix/Hystrix/wiki/Configuration#execution.isolation.strategy

Or, you Can write your own Hystrix Concurrency Strategy, like my pull request:
https://github.com/spring-cloud/spring-cloud-netflix/pull/2509

All 5 comments

@daniellavoie thanks

@daniellavoie It's working for me ; I not set a RequestInterceptor bean ;Now I put it and the code is this
@Bean public RequestInterceptor oauth2FeignRequestInterceptor() { return requestTemplate -> { Object details = SecurityContextHolder.getContext().getAuthentication().getDetails(); if (details instanceof OAuth2AuthenticationDetails) { String tokenValue = ((OAuth2AuthenticationDetails) details).getTokenValue(); requestTemplate.header("Authorization", "bearer " + tokenValue); } }; }
but I'm not sure the code will work good because when I remove the config hystrix.shareSecurityContext from the application.yml the app is work good also

Please provide more information as to what "not working" means

@Comup-X
I think it's because of hystrix's default isolation strategy THREAD , using this Can never propagate ThreadLocal.

Maybe you should try to set isolation strategy of hystrix to SEMAPHORE,
reference: https://github.com/Netflix/Hystrix/wiki/Configuration#execution.isolation.strategy

Or, you Can write your own Hystrix Concurrency Strategy, like my pull request:
https://github.com/spring-cloud/spring-cloud-netflix/pull/2509

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Was this page helpful?
0 / 5 - 0 ratings