jwt概念
json web token,参看jwt入门教程-阮一峰
spring security参考文章
实操:
Spring Security系列(内有目录)
my demo:
springSecurityDemo
自定义provider实现方式
一般用两种:
实现 AuthenticationProvider接口
好处,因为只是个接口,提供了最原始的两个函数:支持类型与验证;
所以可以写很多自定义的东西,也不需要强制使用userDetailsService。
继承AbstractUserDetailsAuthenticationProvider抽象类
内部已经实现了authenticate验证方式,需要提供两个实现方法:
//身份验证
protected abstract void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException;
//获取用户信息(从数据源)
protected abstract UserDetails