• SpringBoot 集成Shiro


     

    Shiro的由来? 

    对于一个真正为其存在提供良好案例的框架,以及因此您使用它的理由,它应该满足其他替代方案无法满足的需求。为了理解这一点,我们需要了解Shiro的历史以及创建时的替代方案。

    在2008年进入Apache软件基金会之前,Shiro已经有5年的历史,之前被称为JSecurity项目,该项目始于2003年初。2003年,Java应用程序开发人员的通用安全替代方案并不多 - Java认证和授权服务,也称为JAAS。JAAS存在许多缺点 - 虽然其身份验证功能在某种程度上是可以容忍的,但授权方面使用起来很麻烦且令人沮丧。此外,JAAS严重依赖于虚拟机级安全性问题,例如,确定是否应允许在JVM中加载类。作为一名应用程序开发人员,我更关心应用程序最终用户可以做什么,而不是我的代码可以在JVM中做什么。

    由于我当时正在使用的应用程序,我还需要访问一个干净的,与容器无关的会话机制。当时游戏中唯一的会话选择是HttpSessions,它需要一个Web容器,或EBJ 2.1 Stateful Session Beans,它需要一个EJB容器。我需要一些可以与容器分离的东西,可以在我选择的任何环境中使用。

    最后,存在加密问题。有时候我们都需要保证数据安全,但除非你是加密专家,否则Java密码体系结构很难理解。API充满了检查异常,并且使用起来很麻烦。我希望有一个更清洁的开箱即用的解决方案,可以根据需要轻松加密和解密数据。

    因此,从2003年初的安全状况来看,您可以很快意识到在单一,有凝聚力的框架中没有任何东西可以满足所有这些要求。正因为如此,JSecurity,以及后来的Apache Shiro诞生了。

    什么是 Shiro?

    Apache Shiro是一个功能强大且易于使用的Java安全框架,可执行身份验证,授权,加密和会话管理,并可用于保护任何应用程序 - 从命令行应用程序,移动应用程序到最大的Web和企业应用程序。

     Shiro的特性?

    Authentication(认证), Authorization(授权), Session Management(会话管理), Cryptography(加密)被 Shiro 框架的开发团队称之为应用安全的四大基石。

    Authentication(认证):用户身份识别,通常被称为用户“登录”。

    Authorization(授权):访问控制。比如某个用户是否具有某个操作的使用权限。

    Session Management(会话管理):特定于用户的会话管理,甚至在非web 或 EJB 应用程序。

    Cryptography(加密):在对数据源使用加密算法加密的同时,保证易于使用。y

    表结构

    user_info 用户表
    sys_user_role 用户角色关联表 (一对多的关系,一个角色对应多个用户)
                     

    sys_permission 权限表
    sys_role_permission 角色权限关联表 (多对多关系)
                       

    sys_role 角色表

    SpringBoot 及集成Shiro开始搭建

    pom文件

    1.  
      <dependencies>
    2.  
      <dependency>
    3.  
      <groupId>org.springframework.boot</groupId>
    4.  
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    5.  
      </dependency>
    6.  
      <dependency>
    7.  
      <groupId>org.springframework.boot</groupId>
    8.  
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    9.  
      </dependency>
    10.  
      <dependency>
    11.  
      <groupId>net.sourceforge.nekohtml</groupId>
    12.  
      <artifactId>nekohtml</artifactId>
    13.  
      <version>1.9.22</version>
    14.  
      </dependency>
    15.  
      <dependency>
    16.  
      <groupId>org.springframework.boot</groupId>
    17.  
      <artifactId>spring-boot-starter-web</artifactId>
    18.  
      </dependency>
    19.  
       
    20.  
      <!-- shiro 关键包-->
    21.  
      <dependency>
    22.  
      <groupId>org.apache.shiro</groupId>
    23.  
      <artifactId>shiro-spring</artifactId>
    24.  
      <version>1.4.0</version>
    25.  
      </dependency>
    26.  
      <dependency>
    27.  
      <groupId>mysql</groupId>
    28.  
      <artifactId>mysql-connector-java</artifactId>
    29.  
      <scope>runtime</scope>
    30.  
      </dependency>
    31.  
      </dependencies>

    配置文件

    1.  
      spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
    2.  
      spring.datasource.username=root
    3.  
      spring.datasource.password=root
    4.  
      spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    5.  
       
    6.  
      spring.jpa.properties.hibernate.hbm2ddl.auto=update
    7.  
      spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    8.  
      spring.jpa.show-sql= true
    9.  
      spring.thymeleaf.cache=false

    实体类

    用户类

    1.  
      @Entity
    2.  
      public class UserInfo implements Serializable {
    3.  
      @Id
    4.  
      @GeneratedValue
    5.  
      private Integer uid;
    6.  
      @Column(unique =true)
    7.  
      private String username;//帐号
    8.  
      private String name;//名称(昵称或者真实姓名,不同系统不同定义)
    9.  
      private String password; //密码;
    10.  
      private String salt;//加密密码的盐
    11.  
      private byte state;//用户状态,0:创建未认证(比如没有激活,没有输入验证码等等)--等待验证的用户 , 1:正常状态,2:用户被锁定.
    12.  
      @ManyToMany(fetch= FetchType.EAGER)//立即从数据库中进行加载数据;
    13.  
      @JoinTable(name = "SysUserRole", joinColumns = { @JoinColumn(name = "uid") }, inverseJoinColumns ={@JoinColumn(name = "roleId") })
    14.  
      private List<SysRole> roleList;// 一个用户具有多个角色
    15.  
      // 省略setget方法
    16.  
       
    17.  
      }

    角色类

    1.  
      @Entity
    2.  
      public class SysRole {
    3.  
      @Id@GeneratedValue
    4.  
      private Integer id; // 编号
    5.  
      private String role; // 角色标识程序中判断使用,如"admin",这个是唯一的:
    6.  
      private String description; // 角色描述,UI界面显示使用
    7.  
      private Boolean available = Boolean.FALSE; // 是否可用,如果不可用将不会添加给用户
    8.  
       
    9.  
      //角色 -- 权限关系:多对多关系;
    10.  
      @ManyToMany(fetch= FetchType.EAGER)
    11.  
      @JoinTable(name="SysRolePermission",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="permissionId")})
    12.  
      private List<SysPermission> permissions;
    13.  
       
    14.  
      // 用户 - 角色关系定义;
    15.  
      @ManyToMany
    16.  
      @JoinTable(name="SysUserRole",joinColumns={@JoinColumn(name="roleId")},inverseJoinColumns={@JoinColumn(name="uid")})
    17.  
      private List<UserInfo> userInfos;// 一个角色对应多个用户
    18.  
      // 省略setget方法
    19.  
      }

    权限类

    1.  
      @Entity
    2.  
      public class SysPermission implements Serializable {
    3.  
      @Id@GeneratedValue
    4.  
      private Integer id;//主键.
    5.  
      private String name;//名称.
    6.  
      @Column(columnDefinition="enum('menu','button')")
    7.  
      private String resourceType;//资源类型,[menu|button]
    8.  
      private String url;//资源路径.
    9.  
      private String permission; //权限字符串,menu例子:role:*,button例子:role:create,role:update,role:delete,role:view
    10.  
      private Long parentId; //父编号
    11.  
      private String parentIds; //父编号列表
    12.  
      private Boolean available = Boolean.FALSE;
    13.  
      @ManyToMany
    14.  
      @JoinTable(name="SysRolePermission",joinColumns={@JoinColumn(name="permissionId")},inverseJoinColumns={@JoinColumn(name="roleId")})
    15.  
      private List<SysRole> roles;
    16.  
      }

    根据以上的代码会自动生成user_info(用户信息表)、sys_role(角色表)、sys_permission(权限表)、sys_user_role(用户角色表)、sys_role_permission(角色权限表)这五张表,为了方便测试我们给这五张表插入一些初始化数据:

    1.  
      INSERT INTO `user_info` (`uid`,`username`,`name`,`password`,`salt`,`state`) VALUES ('1', 'admin', '管理员', '9c77d6384a1d8a1cc581424e6f0e82d8','root30ea1b94d889ccadeb9f89af63317de2', 0);
    2.  
      INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (1,0,'用户管理',0,'0/','userInfo:view','menu','userInfo/userList');
    3.  
      INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (2,0,'用户添加',1,'0/1','userInfo:add','button','userInfo/userAdd');
    4.  
      INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (3,0,'用户删除',1,'0/1','userInfo:del','button','userInfo/userDel');
    5.  
      INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (1,0,'管理员','admin');
    6.  
      INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (2,0,'VIP会员','vip');
    7.  
      INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (3,1,'test','test');
    8.  
      INSERT INTO `sys_role_permission` VALUES ('1', '1');
    9.  
      INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (1,1);
    10.  
      INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (2,1);
    11.  
      INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (3,2);
    12.  
      INSERT INTO `sys_user_role` (`role_id`,`uid`) VALUES (1,1);

    首先要配置的是ShiroConfig类,Apache Shiro 核心通过 Filter 来实现,就好像SpringMvc 通过DispachServlet 来主控制一样。

    类介绍:

    ShiroFilterFactoryBean:是个拦截器,在请求进入控制层前将其拦截,需要将安全管理器SecurityManager注入其中。

    SecurityManager:安全管理器,需要将自定义realm注入其中,以后还可以将缓存、remeberme等注入其中

    1.  
      public interface AuthenticationToken extends Serializable {
    2.  
       
    3.  
      Object getPrincipal();
    4.  
       
    5.  
      Object getCredentials();
    6.  
      }

    AuthenticationToken :

    上面定义了接口源码,主要是两个接口,一个是获取委托人信息,一个是获取证明,常用的是用户名和密码的组合。

    1.  
      @Configuration
    2.  
      public class ShiroConfig {
    3.  
          @Bean
    4.  
          public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    5.  
              System.out.println("ShiroConfiguration.shirFilter()");
    6.  
              ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    7.  
              shiroFilterFactoryBean.setSecurityManager(securityManager);
    8.  
              //拦截器.
    9.  
              Map<String,String> filterChainDefinitionMap = new LinkedHashMap<String,String>();
    10.  
              // 配置不会被拦截的链接 顺序判断
    11.  
              filterChainDefinitionMap.put("/static/**", "anon");
    12.  
              //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了
    13.  
              filterChainDefinitionMap.put("/logout", "logout");
    14.  
              //<!-- 过滤链定义,从上向下顺序执行,一般将/**放在最为下边 -->:这是一个坑呢,一不小心代码就不好使了;
    15.  
              //<!-- authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问-->
    16.  
              filterChainDefinitionMap.put("/**", "authc");
    17.  
              // 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面
    18.  
              shiroFilterFactoryBean.setLoginUrl("/login");
    19.  
              // 登录成功后要跳转的链接
    20.  
              shiroFilterFactoryBean.setSuccessUrl("/index");
    21.  
       
    22.  
              //未授权界面;
    23.  
              shiroFilterFactoryBean.setUnauthorizedUrl("/403");
    24.  
              shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
    25.  
              return shiroFilterFactoryBean;
    26.  
          }
    27.  
       
    28.  
          @Bean
    29.  
          public MyShiroRealm myShiroRealm(){
    30.  
              MyShiroRealm myShiroRealm = new MyShiroRealm();
    31.  
              return myShiroRealm;
    32.  
          }
    33.  
       
    34.  
       
    35.  
          @Bean
    36.  
          public SecurityManager securityManager(){
    37.  
              DefaultWebSecurityManager securityManager =  new DefaultWebSecurityManager();
    38.  
              securityManager.setRealm(myShiroRealm());
    39.  
              return securityManager;
    40.  
          }
    41.  
      }

     自定义realm

    MyShiroRealm继承 AuthorizingRealm,重写doGetAuthorizationInfo授权方法,和doGetAuthenticationInfo认证方法

    1.  
      package com.example.config;
    2.  
       
    3.  
      import com.example.entity.SysPermission;
    4.  
      import com.example.entity.SysRole;
    5.  
      import com.example.entity.UserInfo;
    6.  
      import com.example.service.UserInfoService;
    7.  
      import org.apache.shiro.SecurityUtils;
    8.  
      import org.apache.shiro.authc.*;
    9.  
      import org.apache.shiro.authz.AuthorizationInfo;
    10.  
      import org.apache.shiro.authz.SimpleAuthorizationInfo;
    11.  
      import org.apache.shiro.realm.AuthorizingRealm;
    12.  
      import org.apache.shiro.subject.PrincipalCollection;
    13.  
      import org.apache.shiro.util.ByteSource;
    14.  
       
    15.  
      import javax.annotation.Resource;
    16.  
       
    17.  
      /**
    18.  
      * @ProjectName: springboot-shiro
    19.  
      * @Package: com.example.config
    20.  
      * @ClassName: MyShiroRealm
    21.  
      * @Description:
    22.  
      * @Author: Ni Shichao
    23.  
      * @Version: 1.0
    24.  
      */
    25.  
      public class MyShiroRealm extends AuthorizingRealm {
    26.  
      @Resource
    27.  
      private UserInfoService userInfoService;
    28.  
      @Override
    29.  
      protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    30.  
      System.out.println("权限配置-->MyShiroRealm.doGetAuthorizationInfo()");
    31.  
      SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
    32.  
      UserInfo userInfo = (UserInfo)principals.getPrimaryPrincipal();
    33.  
      for(SysRole role:userInfo.getRoleList()){
    34.  
      authorizationInfo.addRole(role.getRole());
    35.  
      for(SysPermission p:role.getPermissions()){
    36.  
      authorizationInfo.addStringPermission(p.getPermission());
    37.  
      }
    38.  
      }
    39.  
      return authorizationInfo;
    40.  
      }
    41.  
       
    42.  
      /*主要是用来进行身份认证的,也就是说验证用户输入的账号和密码是否正确。*/
    43.  
      @Override
    44.  
      protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
    45.  
      throws AuthenticationException {
    46.  
      System.out.println("MyShiroRealm.doGetAuthenticationInfo()");
    47.  
      // 获取用户的输入的账号.
    48.  
      String username = (String)token.getPrincipal();
    49.  
      // 获取用户的输入的密码
    50.  
      System.out.println(token.getCredentials());
    51.  
      //通过username从数据库中查找 User对象,如果找到,没找到.
    52.  
      //实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法
    53.  
      UserInfo userInfo = userInfoService.findByUsername(username);
    54.  
      System.out.println("----->>userInfo="+userInfo);
    55.  
      if(userInfo == null){
    56.  
      return null;
    57.  
      }
    58.  
       
    59.  
      // 进行认证,将正确数据给shiro处理
    60.  
      // 密码不用自己比对,AuthenticationInfo认证信息对象,一个接口,new他的实现类对象SimpleAuthenticationInfo
    61.  
      /* 第一个参数随便放,可以放user对象,程序可在任意位置获取 放入的对象
    62.  
      * 第二个参数必须放密码,
    63.  
      * 第三个参数放 当前realm的名字,因为可能有多个realm*/
    64.  
      SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
    65.  
      userInfo, //用户名
    66.  
      userInfo.getPassword(), //密码
    67.  
      ByteSource.Util.bytes(userInfo.getSalt()),
    68.  
      getName() //realm name
    69.  
      );
    70.  
      //清除之前的授权信息
    71.  
      super.clearCachedAuthorizationInfo(authenticationInfo.getPrincipals());
    72.  
      // 存入用户对象
    73.  
      SecurityUtils.getSubject().getSession().setAttribute("login", userInfo);
    74.  
      // 返回给安全管理器,securityManager,由securityManager比对数据库查询出的密码和页面提交的密码
    75.  
      // 如果有问题,向上抛异常,一直抛到控制器
    76.  
      return authenticationInfo;
    77.  
      }
    78.  
       
    79.  
      }

    AuthenticationToken 说明

    1.  
      public interface AuthenticationToken extends Serializable {
    2.  
       
    3.  
      Object getPrincipal();
    4.  
       
    5.  
      Object getCredentials();
    6.  
       
    7.  
      }

    上面定义了接口源码,主要是两个接口,一个是获取委托人信息,一个是获取证明,常用的是用户名和密码的组合。

    这里AuthenticationToken只提供接口,一般我们的实体类包含了get/set方法,但是这里抽出了get方法,方便用户自己扩展所需要的实现。

    其中扩展接口HostAuthenticationToken提供了获取用户客户host的功能,源代码如下:

    1.  
      public interface HostAuthenticationToken extends AuthenticationToken {
    2.  
      String getHost();
    3.  
      }

    RememberMeAuthenticationToken提供了记住用户的标识:

    1.  
      public interface RememberMeAuthenticationToken extends AuthenticationToken {
    2.  
       
    3.  
      boolean isRememberMe();
    4.  
       
    5.  
      }

    Controller类说明

    登录过程其实只是处理异常的相关信息,具体的登录验证交给shiro来处理

    1.  
      @Controller
    2.  
      public class HomeController {
    3.  
       
    4.  
      @RequestMapping({"/","/index"})
    5.  
      public String index(){
    6.  
      return"/index";
    7.  
      }
    8.  
       
    9.  
       
    10.  
      @RequestMapping("/login")
    11.  
      public String login(HttpServletRequest request, Map<String, Object> map) throws Exception{
    12.  
      System.out.println("HomeController.login()");
    13.  
      // 登录失败从request中获取shiro处理的异常信息。
    14.  
      // shiroLoginFailure:就是shiro异常类的全类名.
    15.  
      String exception = (String) request.getAttribute("shiroLoginFailure");
    16.  
      System.out.println("exception=" + exception);
    17.  
      String msg = "";
    18.  
      if (exception != null) {
    19.  
      if (UnknownAccountException.class.getName().equals(exception)) {
    20.  
      System.out.println("UnknownAccountException -- > 账号不存在:");
    21.  
      msg = "UnknownAccountException -- > 账号不存在:";
    22.  
      } else if (IncorrectCredentialsException.class.getName().equals(exception)) {
    23.  
      System.out.println("IncorrectCredentialsException -- > 密码不正确:");
    24.  
      msg = "IncorrectCredentialsException -- > 密码不正确:";
    25.  
      } else if ("kaptchaValidateFailed".equals(exception)) {
    26.  
      System.out.println("kaptchaValidateFailed -- > 验证码错误");
    27.  
      msg = "kaptchaValidateFailed -- > 验证码错误";
    28.  
      } else {
    29.  
      msg = "else >> "+exception;
    30.  
      System.out.println("else -- >" + exception);
    31.  
      }
    32.  
      }
    33.  
      map.put("msg", msg);
    34.  
      // 此方法不处理登录成功,由shiro进行处理
    35.  
      return "/login";
    36.  
      }
    37.  
       
    38.  
      @RequestMapping("/403")
    39.  
      public String unauthorizedRole(){
    40.  
      System.out.println("------没有权限-------");
    41.  
      return "403";
    42.  
      }
    43.  
      }

    其它dao层和service的代码就不贴出来了大家直接看代码。

    页面说明

    登录页面

    1.  
      <!DOCTYPE html>
    2.  
      <html lang="en">
    3.  
      <head>
    4.  
      <meta charset="UTF-8">
    5.  
      <title>Login</title>
    6.  
      </head>
    7.  
      <body>
    8.  
      错误信息:<h4 th:text="${msg}"></h4>
    9.  
      <form action="" method="post">
    10.  
      <p>账号:<input type="text" name="username" value="admin"/></p>
    11.  
      <p>密码:<input type="text" name="password" value="123456"/></p>
    12.  
      <p><input type="submit" value="登录"/></p>
    13.  
      </form>
    14.  
      </body>
    15.  
      </html>

    index页面

    1.  
      <!DOCTYPE html>
    2.  
      <html lang="en">
    3.  
      <head>
    4.  
      <meta charset="UTF-8">
    5.  
      <title>index</title>
    6.  
      </head>
    7.  
      <body>
    8.  
       
    9.  
      <div th:text="'欢迎你'+${session.login.username}"></div>
    10.  
      <a th:href="@{/logout}">退出登录</a>
    11.  
      </body>
    12.  
      </html>

    添加用户过程

    1.  
      /**
    2.  
      * 添加用户
    3.  
      * @return
    4.  
      */
    5.  
      @RequestMapping("/userSave")
    6.  
      @RequiresPermissions("userInfo:save")//权限管理;
    7.  
      public String userSave(UserInfo user){
    8.  
      userInfoService.save(user);
    9.  
      return "redirect:userList";
    10.  
      }

     Service中的代码

    1.  
      public void save(UserInfo userInfo) {
    2.  
      String password = userInfo.getPassword();
    3.  
      String[] saltAndCiphertext = UserRegisteAndLogin.encryptPassword(userInfo.getUsername(),password);
    4.  
      userInfo.setSalt(saltAndCiphertext[0]);
    5.  
      userInfo.setPassword(saltAndCiphertext[1]);
    6.  
      userInfoDao.save(userInfo);
    7.  
      }

    密码加密处理

    1.  
      /**
    2.  
      * 用户注册时加密用户的密码
    3.  
      * 输入密码明文 返回密文与盐值
    4.  
      * @param password
    5.  
      * @return 第一个是密文 第二个是密码盐值
    6.  
      */
    7.  
      public static String[] encryptPassword(String username,String password)
    8.  
      {
    9.  
      String salt = new SecureRandomNumberGenerator().nextBytes().toHex(); //生成盐值
    10.  
      salt = username+salt;
    11.  
      int hashIterations = 2;//加密的次数
    12.  
      String hashAlgorithmName = "md5";//加密方式
    13.  
      Object simpleHash = new SimpleHash(hashAlgorithmName, password,
    14.  
      salt, hashIterations);
    15.  
      String[] strings = new String[]{salt, simpleHash.toString()};
    16.  
      return strings;
    17.  
      }
     

    html页面

    1.  
      <!DOCTYPE html>
    2.  
      <html lang="en">
    3.  
      <head>
    4.  
      <meta charset="UTF-8">
    5.  
      <title>添加用户页面</title>
    6.  
      </head>
    7.  
      <body>
    8.  
       
    9.  
       
    10.  
      <form action="/userInfo/userSave" method="post">
    11.  
      <p>昵称:<input type="text" name="name" /></p>
    12.  
      <p>账号:<input type="text" name="username" /></p>
    13.  
      <p>密码:<input type="text" name="password" /></p>
    14.  
      <p><input type="submit" value="保存"/></p>
    15.  
      </form>
    16.  
      </body>
    17.  
      </html>
    wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

    测试

    http://localhost:8080/login 页面

    wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

    登录成功跳转 index 页面

    wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

    上面这些操作时候触发MyShiroRealm.doGetAuthorizationInfo()这个方面,也就是权限校验的方法。

    可以在数据库中修改不同的权限进行测试,deml中有队用户的增删查改,就不展示了,大家可以下载demo自行测试。

    github地址:

    https://github.com/xiaonongOne/springboot-shiro

    摘自:https://blog.csdn.net/qq_31984879/article/details/88366199

  • 相关阅读:
    500内部服务器错误
    silverlight中实现页面传值
    每个程序员必备的10种工具
    ora-12514:TNS:listener does not currently know of service requested in connect descriptor
    利用VBA 宏实现vc6.0的自动添加注释和自动取消注释
    plsql developer (在8.04版本中试过可用)
    修改Oracle数据库字符集
    80端口被占用(端口检查)解决
    sql server分页
    解决问题 “You don't have permission to access /index.html on this server.”
  • 原文地址:https://www.cnblogs.com/yelanggu/p/11283553.html
Copyright © 2020-2023  润新知