本部分连接:
aop与spring security,
一般在服务层使用spring aop来保护方法调用. 如果在领域层,则使用aspectJ来保护. 当然保护web请求,直接使用web拦截器
存储SecurityContext
使用SecurityContextPersistenceFilter,可以在不同的线程中共享SecurityContext,在request结束后清空SecurityContext.
AuthenticationManager
验证完用户后,会将用用认证信息传保存到SecurityContextHolder里.
AccessDecissionManager
spring security message localize
spring security报错信息的本地化.
核心服务
认证管理者,生产商管理者,认证生产商
ProviderManager调用AuthenticationProvider来验证用户,如DaoAuthenticationProvider,AnonymousAuthenticationProvider,LdapAuthenticationProvider等.
DaoAuthenticationProvider可以通过设置userDetailService,passwordEncoder来实现.
in-memory Authentication可以不通过数据库来存储用户信息.
通过设置xx来实现.
密码机制
不能直接存储密码字符,也不能直接使用MD5或SHA来加密密码.甚至是一个混淆值.Bcrypt被设计为非常慢以阻碍离线破解. 使用org.springframework.security.bcrypt.BCryptPasswordEncoder是一个好的选择.
如果是一个遗留系统,则需要选择原有的密码类型,因为hash是不可逆的.即使值受损害也不会立即暴露.一旦编码,就无法暴露.
使用混淆值可以使攻击速度放慢.