OAuth2ClientContext (spring-security-oauth2) not persisted in Redis when using spring-session and spring-cloud-security

前端 未结 3 2022
旧巷少年郎
旧巷少年郎 2020-12-30 10:40

Thanks a lot in advance for reading this question.

Setup

I am using:

  • spring-security-oauth2:2.0.7.RELEASE
  • spring-
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 11:13

    @dave-syer hint was correct.

    I post here the configuration which can be used to setup the RequestContextFilter and enable spring-session persistence of spring-security-oauth objects. In case this can help someone...

    @Configuration
    public class RequestContextFilterConfiguration {
    
        @Bean
        @ConditionalOnMissingBean(RequestContextFilter.class)
        public RequestContextFilter requestContextFilter() {
            return new RequestContextFilter();
        }
    
        @Bean
        public FilterRegistrationBean requestContextFilterChainRegistration(
                @Qualifier("requestContextFilter") Filter securityFilter) {
            FilterRegistrationBean registration = new FilterRegistrationBean(securityFilter);
            registration.setOrder(SessionRepositoryFilter.DEFAULT_ORDER + 1);
            registration.setName("requestContextFilter");
            return registration;
        }
    }
    

提交回复
热议问题