回顾
《引入Security遇到的问题》前文基本引入seciruy,就准备弄登录和注册模块了
这里有个问题,很久之前,我也打算吧seciruy当成一个模块来弄,不过具体怎么去弄,有点不清醒,之前的老项目jfun、或者jfun-cloud应该会有类似的问题
现在的处理方法
现在的处理方法在下图模块的基础之上
mall-security
component
|--------------JwtAuthenticationTokenFilter JWT登录授权过滤器
|--------------RestAuthenticationEntryPoint 自定义返回结果:未登录或登录过期
|--------------RestfulAccessDeniedHandler 自定义返回结果:没有权限访问时
config
|--------------IgnoreUrlsConfig用于配置不需要保护的资源路径 如Swagger
|—-------------SecurityConfig 对SpringSecurity的配置的扩展,支持自定义白名单资源路径和查询用户逻辑
util
|--------------JwtTokenUtil JwtToken生成的工具类
- 主项目基础seciruy配置类
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class MallSecurityConfig extends SecurityConfig {
@Autowired
private IUmsAdminService adminService;
@Bean