项目原来是单体架构,现拆分成spring cloud微服务架构。
如下两个方法的切入点都是在ShiroConfig配置类(@Configuration)中@Bean注入的:
1 shiroFilterFactoryBean -> JwtFilter中的onAccessDenied()
-> 无token:直接放过
--> 登录/login
---> 远程调用oauth模块
----> 去验证(username,password) + accountService.generateToken()
-----> jwtUtils生成token,返回
--> 其它不需要登录的业务模块
-> 有token:jwtUtils校验token
--> 合法未过期,放过
--> 不合法已过期,重新登录
2 securityManager -> Realm
-> 认证doGetAuthenticationInfo(有token时才会走这个方法)
--> jwtUtils获取userId
---> 远程调用user模块
----> userService查询userInfo,放入上下文中SimpleAuthenticationInfo(便于ShiroUtils.getProfile()获取当前登录的用户信息),返回
-> 鉴权doGetAuthorizationInfo
--> 远程调用Authority(role + permission)模块
---> roleService.byUserId(...)查询role,role查询permission,返回