springboot整合shiro大体上的思路:

1.自定义一个类Realm extends AuthorizingRealm{}

主要是对token授权和认证

重写2个方法

doGetAuthorizationInfo  //授权
doGetAuthenticationInfo  //认证
认证 代码中手动加上对token校验的判断

2.自定义一个@Configuration类ShiroConfig

ShiroConfig类主要做3个事情

将自定义的Realm注册bean

将realm对象与securityManager对象关联  

securityManager.setRealm(realm);

将securityManager对象与ShiroFilterFactoryBean对象关联

shiroFilterFactoryBean.setSecurityManager(getDefaultWebSecurityManager);

 

3.整合jwt

先定义公共类JwtUtils

其中定义三个方法 作用分别为token生成  token校验  token是否过期

 

在realm类的认证doGetAuthenticationInfo方法中调用JwtUtils解析token和登录用户是否满足条件

满足则返回AuthenticationInfo对象 对象中包含profile token name

(只需要定义个profile就好了  profile就是登录的用户信息  可以再定义一个用户实体类  把用户信息放入实体类中那这个对象类就是profile)

 

 

 

 

 

边学边整理思路  详细的得边敲边看代码






相关文章:

  • 2021-09-25
  • 2021-09-25
  • 2017-11-21
  • 2019-01-20
  • 2021-09-25
  • 2021-09-25
  • 2021-09-25
  • 2021-09-25
猜你喜欢
  • 2021-10-02
  • 2019-12-10
  • 2021-11-23
  • 2021-09-15
  • 2021-09-25
  • 2021-09-25
  • 2021-09-25
  • 2021-09-25
相关资源
相似解决方案