Shiro安全框架实现授权逻辑

Shiro面试题(二十道) SecurityManager才是实际的执行者。Realm:域,shiro从Realm获取安全数据(如用户、角色、权限),就是说SecurityManager要验证用户身份,那么它需要从Realm获取相应的用户进行比较以确定用户身份是否合法;Shiro提供了CredentialsMatcher的散列实现HashedCredentialsMatcher,和PasswordMatcher不同的是,它只是用于密码验证,且可以提供自己的盐,而不是随机生成盐,且生成密码散列值的算法需要自己写,因为能提供自己的盐。.. 阅读详情

Shiro是一个强大且易用的Java安全框架,执行身份验证、授权、密码和会话管理。

前言:
开发工具:idea、MySQL
开发技术:MyBatis、Spring Boot、Shiro

创建数据库及测试表

-- 创建数据库
CREATE DATABASE IF NOT EXISTS shoop DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
-- 创建用户表
create table shiro_user(
  u_id int auto_increment primary key,
  password varchar(50),
  user_name VARCHAR(100)
)
insert into shiro_user(password,user_name) values('admin','admin@shiro.con'),('123456','test@shiro.con')
-- 角色表
create table shiro_user_role(
  r_id int auto_increment primary key,
  role_name varchar(50),
  user_name VARCHAR(100)
)
insert into shiro_user_role(role_name,user_name) values('admin','admin@shiro.con'),('test','test@shiro.con')
-- 角色权限表
create table shiro_role_permission(
  p_id int auto_increment primary key,
  role_name varchar(50),
  perm_name VARCHAR(100)
)
insert into shiro_role_permission(role_name,perm_name) values('admin','home_manage.html'),
('admin','get.html'),('admin','delete.html'),('test','add.html')

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.springboot</groupId>
    <artifactId>five</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>five</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- spring boot mybatis依赖 -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.2.0</version>
        </dependency>
        <!-- 添加thymeleaf支持:类似于jsp的视图模板 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

         <!-- Shiro依赖 -->
        <dependency>
            <groupId>com.github.theborakompanioni</groupId>
            <artifactId>thymeleaf-extras-shiro</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>1.2.3</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

application.properties

#数据源
spring.datasource.url=jdbc:mysql://localhost:3306/shoop?serverTimezone=Asia/Shanghai&useSSL=false&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

实体类(entity)

//用户表
public class ShiroUser {
    private int u_id;
    private String user_name;
    private String password;
    //省略getter和setter方法    
    }
//角色表
public class Role {
    private int r_id;
    private String role_name;
    private String user_name;
    //省略getter和setter方法    
    }
//角色权限表
public class Pejuesejuese   private int p_id;
    private String role_name;
    private String perm_name;
    //省略getter和setter方法   
    } 

接口(mapper)

//查询用户
@Mapper
public interface ShiroUserMapper {
    public ShiroUser findByName(@Param(value = "user_name") String user_name);
}
//查询用户角色
@Mapper
public interface RoleMapper {
    public Role RoleName(@Param(value = "user_name") String user_name);
}
//查询角色的权限
@Mapper
public interface PermissionMapper {
    public List<Permission> PermissionPerName(@Param(value = "role_name") String role_name);
}

myBatis配置文件(xml)

<!-- 查询用户 -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.springboot.mapper.ShiroUserMapper">
    <select id="findByName" resultType="com.springboot.entity.ShiroUser">
         select * from shiro_user where user_name=#{user_name}
    </select>
</mapper>
<!-- 查询用户角色-->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.springboot.mapper.RoleMapper">
    <select id="RoleName" resultType="com.springboot.entity.Role">
         select *from shiro_user_role where user_name=#{user_name}
    </select>
</mapper>
<!-- 查询角色的权限-->
<?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.springboot.mapper.PermissionMapper">
<select id="PermissionPerName" resultType="com.springboot.entity.Permission">
        select *from shiro_role_permission where role_name=#{role_name}
    </select>
</mapper>

业务层(service)

//查询用户
public interface ShiroUserService {
    public ShiroUser findByName(@Param(value = "user_name") String user_name);
}
//查询用户角色
public interface RoleService {
    public Role RoleName(@Param(value = "user_name") String user_name);
}
//查询角色的权限
public interface PermissionService {
    public List<Permission> PermissionPerName(@Param(value = "role_name") String role_name);
}

业务实现层(service.impl)

//查询用户
@Service
public class ShiroUserServiceImp implements ShiroUserService {
    @Resource
    private ShiroUserMapper shiroUserMapper;
    @Override
    public ShiroUser findByName(String user_name) {
        //ShiroUser user = shiroUserMapper.findByName(user_name);
        return shiroUserMapper.findByName(user_name);
    }
}
//查询用户角色
@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    public RoleMapper rolemapper;
    @Override
    public Role RoleName(String user_name) {
        //Role user = rolemapper.RoleName(user_name);
        return rolemapper.RoleName(user_name);
    }
}
//查询角色的权限
@Service
public class PermissionServiceImpl implements PermissionService {
    @Resource
    public PermissionMapper permissionMapper;
    @Override
    public List<Permission> PermissionPerName(String role_name) {
        //List<Permission> permission = permissionMapper.PermissionPerName(role_name);
        return permissionMapper.PermissionPerName(role_name);
    }
}

逻辑控制层(Controller)

public class UserRealm extends AuthorizingRealm {

     //认证
    @Resource
    public ShiroUserService shiroUserService;
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
        ShiroUser user = shiroUserService.findByName(token.getUsername());
        //2.判断密码
        return new SimpleAuthenticationInfo(user,user.getPassword(),"");
    }
    //授权
    @Resource
    public RoleService roleService;
    @Resource
    public PermissionService permissionService;
    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
        SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
        //获取当前用户的ID
        Subject subject = SecurityUtils.getSubject();
        ShiroUser user  = (ShiroUser) subject.getPrincipal();
        //查询用户的角色(身份)
        Role role = roleService.RoleName(user.getUser_name());
        //查询用户角色权限
        List<Permission> permission = null;
        try {
            permission = permissionService.PermissionPerName(role.getRole_name());
        } catch (Exception e) {
            e.printStackTrace();
        }
        Set<String> permissions = new HashSet<String>();
        for(Permission p:permission){
            permissions.add(p.getPerm_name());
        }
        info.setStringPermissions(permissions);
        return info;
    }
}

@Configuration
public class ShiroConfig {
    //创建Realm
    @Bean(name = "userRealm")
    public UserRealm getUserRealm(){
        UserRealm userRealm = new UserRealm();
        return userRealm;
    }

    //创建DefaultWebSecurityManager(安全管理器,关联Realm)
    @Bean(name = "securityManager")
    public DefaultWebSecurityManager getDefaultWebSecurityManager(@Qualifier("userRealm") UserRealm userRealm){
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        //关联Realm
        securityManager.setRealm(userRealm);
        return securityManager;
    }

    //创建ShiroFilterFactoryBean(用户主体,把操作交给SecurityManager)
    @Bean(name = "DefaultWebSecurityManager")
    public ShiroFilterFactoryBean getShiroFilterFactoryBean(@Qualifier("securityManager") DefaultWebSecurityManager securityManager){
        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
        //设置安全管理器
        shiroFilterFactoryBean.setSecurityManager(securityManager);
        //添加shiro内置过滤器,可以实现相关权限拦截
        Map<String,String> filterMap = new LinkedHashMap<String, String>();
        filterMap.put("/tet/test","anon");
        filterMap.put("/tet/login","anon");
        //Tips:当授权拦截后,Shiro会自动跳转到未授权界面
        filterMap.put("/tet/add", "perms[add.html]");
        filterMap.put("/tet/update", "perms[get.html]");
        filterMap.put("/tet/delete", "perms[delete.html]");
        filterMap.put("/tet/**","authc");
        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterMap);
        shiroFilterFactoryBean.setLoginUrl("/tet/toLogin");
        shiroFilterFactoryBean.setSuccessUrl("/tet/hello");
        shiroFilterFactoryBean.setUnauthorizedUrl("/tet/noAuth");
        return shiroFilterFactoryBean;
    }

    //配置ShiroDialect,用于thymeleaf和shiro标签的配合使用
    @Bean
    public ShiroDialect getShiroDialect(){
        return new ShiroDialect();
    }
}


@RequestMapping("/tet")
@Controller
public class testController {
    @RequestMapping("/login")
    public String login(String user_name, String password){

        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken(user_name,password);
        try {
            subject.login(token);
            return "test";
        } catch (AuthenticationException e) {
            return "a";
        }
    }
    @RequestMapping("/test")
    public String test(){
        return "home";
    }
    @RequestMapping("/add")
    public String add() {
        return "add";
    }
    @RequestMapping("/update")
    public String update(){
        return "update";
    }
    @RequestMapping("/delete")
    public String delete(){
        return "delete";
    }
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }
    @RequestMapping("/hello")
    public String hello(){
        return "a";
    }
    @RequestMapping("/noAuth")
    public String noAuth(){
        return "s";
    }
}

登录HTML

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="/tet/login" method="post">
    用户名:<input type="text" name="user_name"><br>
    密码:<input type="password" name="password"><br>
    <input type="submit" value="login">
</form>
</body>
</html>

首页HTML

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<shiro:hasPermission name="add.html">
    用户添加:<a href="add">添加用户</a><br>
</shiro:hasPermission>

<shiro:hasPermission name="get.html">
    用户修改:<a href="update">修改用户</a><br>
</shiro:hasPermission>

<shiro:hasPermission name="delete.html">
    用户删除:<a href="delete">删除用户</a><br>
</shiro:hasPermission>

</body>
</html>

项目源码https://pan.baidu.com/s/1Lcn_ovMz48UoKz7p_xQsHA提取码:m55s

Shiro权限框架深入浅出.pdf Apache Shiro 是 Java 的一个安全框架。我们经常看到它被拿来和 Spring 的 Security 来对比。大部分人认为 Shiro 比 Security 要简单 立即下载

相关推荐

用Keil5给CH552G编程:手把手配置8051开发环境+LED闪烁实战

本文详细介绍了如何使用Keil5为CH552G单片机配置8051开发环境,并完成LED闪烁实战。从获取必要软件、安装WCH器件库到创建工程、编写程序及烧录,手把手指导开发者避开常见陷阱,特别适合从STC转向CH552G的开发者。

weixin_30733003的博客 538

Java初级面试一般问题

java语言的基本特性? 面向对象、跨平台、多线程、异常处理机制、自动垃圾回收机制。 java程序的执行过程? 编译、运行—将java原码(.java文件)通过编译器(javac.exe)编译成JVM文件(.class文件) 将JVM文件通过java.exe执行输出结果。 java中的数据类型? 基本数据类型(byte、short、char、int、long、float、double、boolean)。 引用数据类型(类-class、接口-interface、数组-[])。 int 与In..

weixin_43511745的博客 872

Silvaco Atlas入门指南——从零开始掌握半导体器件仿真

本文为Silvaco Atlas半导体器件仿真软件的入门指南,详细介绍了从零开始掌握该工具的核心流程。内容涵盖Atlas的基本概念、仿真流程、核心文件(输入、结构、输出文件)、交互式与批处理两种操作模式,并逐步演示了如何从定义网格、划分区域、设置电极到进行掺杂、选择物理模型并求解,最终获取和分析器件特性的完整步骤。旨在帮助微电子相关专业人员和工程师快速上手这一强大的“数字实验室”,提升半导体器件设计与研发效率。

weixin_29306317的博客 399

Shiro权限框架认证和授权原理介绍

1、简介shiro是一个安全框架,是Apache的一个子项目。shiro提供了:认证、授权、加密、会话管理、与web集成、缓存等模块。   1.1、模块介绍Authentication:用户身份识别,可以认为是登录;Authorization:授权,即权限验证,验证某个已认证的用户是否拥有某个权限;即判断用户是否能做事情,常见的如:验证某个用户是否拥有某个角色。或者细粒度的验证某个用户对某个资源是...

IT飞岳的博客 1万+

【亲测】ubuntu20.4 安装CUDA11.8

一步一步搭建C++ CUDA CUDNN TENSORRT OPENCV DNN ONNXRUNTIME推理环境

weixin_40950590的博客 3894

【大模型】一图看懂3D因果卷积!

本文将系统性地介绍从1D到3D的因果卷积原理,通过直观的动图演示帮助读者理解其工作机制,并重点探讨3D因果卷积在大规模视频生成中的独特价值和应用前景。

xian0710830114的专栏 2198

Apache Shiro ⒉认证和授权逻辑概述

Apache Shiro 的认证和授权流程概述.

O_o 1106

RISC-V IP中的ITCM/DTCM与Slave-AHB接口设计解析

本文深入解析RISC-V IP中ITCM/DTCM与Slave-AHB接口的设计要点,涵盖TCM架构原理、总线协议实现及性能优化策略。通过实际案例展示如何实现单周期访问延迟,解决跨时钟域同步等关键问题,为嵌入式系统提供确定性内存访问方案。特别探讨了AHB总线仲裁机制和RTL实现技巧,助力开发者构建高效可靠的RISC-V处理器子系统。

weixin_28419039的博客 529

shiro-基本原理和逻辑配置

https://jinnianshilongnian.iteye.com/blog/2049092 https://my.oschina.net/huangyong/blog/215153 http://shiro.apache.org/articles.html http://shiro.apache.org/documentation.html

大帅的博客 6131

ArcGIS新手必看:用Landsat 8数据计算植被覆盖度的完整流程(附DEM裁剪技巧)

本文为ArcGIS新手提供了使用Landsat 8数据计算植被覆盖度的完整流程指南。详细讲解了从数据预处理、NDVI计算到基于像元二分模型反演植被覆盖度的核心步骤,并重点分享了利用DEM进行精确裁剪的实用技巧,帮助用户高效完成地表信息提取与分析。

weixin_29279047的博客 237

PCL 直通滤波

内容抄自优快云点云侠:[【2024最新版】PCL点云处理算法汇总(C++长期更新版)](https://blog.youkuaiyun.com/qq_36686437/article/details/114160640)。质量无忧,永久免费,可放心复制粘贴。

m0_51204289的博客 903

ssm+shiro

shiro原理 框架解释:  subject:主体,可以是用户也可以是程序,主体要访问系统,系统需要对主体进行认证、授权。 securityManager:安全管理器,主体进行认证和授权都 是通过securityManager进行。它包含下面的认证器和授权器。 authenticator:认证器,主体进行认证最终通过authenticator进行的。  authorizer:授权器,主体

mengyong1108的博客 497

Python爬虫实战:股票历史数据抓取与量化回测全流程详解

我们以**东方财富网(eastmoney.com)和雪球网(xueqiu.com)**为主要目标,演示如何爬取A股历史行情。最常用的HTTP请求库,简单易用,适合静态页面数据请求。本文详细介绍了从股票历史数据抓取到简单回测的完整流程,代码示例基于最新技术,结构清晰,适合初学者和进阶者学习量化投资实战。希望对你入门Python爬虫和量化交易有所帮助!

2201_76125261的博客 1778

03-Apache Shiro 安全框架(练一个)

Shiro安全框架简介 Shiro概述 Shiro是apache旗下一个开源安全框架,它对软件系统中的安全认证相关功能进行了抽封装,实现了用户身份认证,权限授权、加密、会话管理等功能,组成了一个通用的安全认证框架。使用shiro就可以非常快速的完成认证、授权等功能的开发,降低系统成本。 用户在进行资源访问时,要求系统要对用户进行权限控制,其具体流程如图所示: Shiro概要架构 在概念层面,Shiro 架构包含三个主要的理念,如图所示: 其中: Subject :主体对象,负责提交用户认证和授权信息。

雨田说码 4803

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Java学习四阶段-03 Apache Shiro安全框架

Shiro安全框架简介 Shiro概述 Shiro是apache旗下一个开源安全框架,它对软件系统中的安全认证相关功能进行了抽封装,实现了用户身份认证,权限授权、加密、会话管理等功能,组成了一个通用的安全认证框架。使用shiro就可以非常快速的完成认证、授权等功能的开发,降低系统...

奔跑的小猫 332

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

自己测试使用shiro安全框架

今天学了一下shiro安全框架根据别人的文章实验成功 特地记录一下 原文转自:https://www.jianshu.com/p/7f724bec3dc3 我用的是springboot框架集成的 1 项目架构 2 导入依赖 <!-- shiro安全框架--> <dependency> <groupId>...

duanduan339的博客 707

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

shiro安全框架

shiro安全框架

asmall_cat的博客 1218

三.Apache Shiro 安全框架

Shiro安全框架简介 Shiro概述 Shiro是apache旗下一个开源安全框架,它对软件系统中的安全认证相关功能进行了抽封装,实现了用户身份认证,权限授权、加密、会话管理等功能,组成了一个通用的安全认证框架。使用shiro就可...

qq_57549760的博客 402

跟我学Shiro

第一章 Shiro简介——《跟我学Shiro》 博客分类:   跟我学Shiro 跟我学shiro    目录贴: 跟我学Shiro目录贴   1.1  简介 Apache Shiro是Java的一个安全框架。目前,使用Apache Shiro的人越来越多,因为它相当简单,对比Spring Security,可能没有Spring Security做的功能强大...

Alpha@晓风 148

Shiro安全框架简介及认证操作(PROJECT04_DAY03_02)

1.Shiro安全框架简介 1.1 Shiro概述 Shiro是apache旗下一个开源安全框架,它将软件系统的安全认证相关的功能抽取出来,实现用户身份认证,权限授权、加密、会话管理等功能,组成了一个通用的安全认证框架。使用shiro就可以非常快速的完成认证、授权等功能的开发,降低系统成本。 用户在进行资源访问时,要求系统要对用户进行权限控制,其具体流程如图-1所示: 图-1 1.2 Shiro概要架构 在概念层面,Shiro 架构包含三个主要的理念,如图-2所示: 图-2 其中: Subject :

weixin_47253919的博客 2399

Shiro

Shiro 1.Shiro介绍 shiro一款一款主流的Java安全框架,不依赖任何容器,可以运行在Java SE和Java EE项目中,主要功能使对访问系统的用户进行身份认证、授权、会话管理、加密操作。 2.Shiro核心组件 **Subject:**主体,代表当前的用户,可使用SecurityUtil.getSubject()获取当前的Subject对象。所有的Subject都绑定到SecurityManager,与Subject的所有交互都会委托给SecurityManager,可以把Subjec

机械佬也想学编程 179

Shiro学习笔记

目录 是什么? 为什么学? 怎么学? 是什么? Shiro 官网:Apache Shiro | Simple. Java. Security. 简单介绍: Apache Shiro是一个强大且易用的的java安全框架,执行身份验证、授权、密码和会话管理。Shiro不依赖任何容器,可以运行在Java SE 和 Java EE项目中,简单理解Shiro就是用来解决安全管理的系统化框架,更直白一点就是我们以前自己写的认证、授权、加密等操作,换成使用别人写好的框架去实现,逻辑...

weixin_47255175的博客 857

SpringBoot整合Shiro学习DEMO

SpringBoot整合Shiro学习DEMO ​ 什么是Shiro?Shiro是一款主流的Java安全框架,它不依赖任何容器,可以运行在JavaSE还有JavaEE项目中,它的主要作用是对访问系统的用户进行身份认证、授权、会话管理、加密等操作。 1、Shiro主要的组件 ​ 在Shiro中 有角色(role)、权限(perms) 会给角色赋予权限,在给用户赋予角色 1、UsernamePasswordToken:Shiro用来封装用户的登录信息,使用用户的登录信息来创建Token。 2、SecurityM

qq_43157085的博客 280
上一篇: SpringBoot+MyBatis实现登录和拦截器
下一篇: form表单向后端提交数据后端用List接收
与黑夜为伍
博客等级 码龄7年 19粉丝 80原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值