Spring security的执行流程
authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
AuthenticationManager 默认使用的是 ProviderManager,它是 AuthenticationManager 的一个默认实现。ProviderManager 管理一个或多个 AuthenticationProvider,并依次调用它们进行认证。
默认配置:
ProviderManager 默认会注册一个 DaoAuthenticationProvider,这是 Spring Security 中最常用的认证提供者。DaoAuthenticationProvider 会根据 UserDetailsService 来加载用户数据,并通过 PasswordEncoder 来验证密码。
AuthenticationManager 工作原理:
AuthenticationManager authenticationManager = new ProviderManager(Arrays.asList(new DaoAuthenticationProvider()));
ProviderManager 会依次检查各个 AuthenticationProvider 是否支持当前的 Authentication 类型。如果支持,则交给相应的 AuthenticationProvider 来进行认证。
上一篇:dubbo支持多种协议:
下一篇:再次理解:事务传播机制
相关文章
-
Kafka 如何保证消息的顺序性?
Consumer ,拉取到消息后,写到 N 个内存 queue,具有相同 key 的数据都到同一个内存 queue 。然后,对于 N 个线程,每个线程分别消费一个内存 queue 即可,这样就能保证顺序性。
NEW个对象 2025-01-11
-
Redis删除过期key的策略
Redis删除过期key的策略有三种
NEW个对象 2024-10-22
-
Kafka保证消息不丢失主要从三个方面考虑
Kafka保证消息不丢失主要从三个方面考虑
NEW个对象 2026-07-07