securiy userCache不要调用自定义缓存

时间:2019-07-11 08:53:02

标签: security

spring boot版本:2.2.0M4 我使用的是自定义缓存,但是会话中有为什么仍存在用户详细数据

    //springCache use redis
    @Bean
    public SpringCacheBasedUserCache springCacheBasedUserCache() {
        try {
            RedisCacheManager redisCacheManager = applicationContext.getBean(RedisCacheManager.class);
            Cache cache = redisCacheManager.getCache("userCache");
            Assert.notNull(cache, () -> "!");
            return new SpringCacheBasedUserCache(cache);
        } catch (Exception e) {
            Assert.hasText(e.getMessage(), "!");
        }
        return null;
    }

    //userDetail
    @Autowired
    private MyUserDetailsService myUserDetailsService;
    @Bean
    public DaoAuthenticationProvider daoAuthenticationProvider() {
        DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
        provider.setHideUserNotFoundExceptions(false);
        provider.setUserDetailsService(myUserDetailsService);
        provider.setPasswordEncoder(passwordEncoder());
        provider.setUserCache(springCacheBasedUserCache());
        return provider;
    }



@Autowired
private DaoAuthenticationProvider daoAuthenticationProvider;

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.authenticationProvider(daoAuthenticationProvider);
}

呼叫redis数据,会话数据为空

0 个答案:

没有答案