spring boot 前后端分离整合shiro(一)快速上手

spring boot 前后端分离整合shiro(一)快速上手

前言

第一次写博客,可能有些地方表达不是很好,不对的地方欢迎大家指出。

shiro简介

shiro是apache的一个权限框架,相比spring security更简单易用。在使用shiro前一定要对它执行的一个基本流程、内部组件有一个大概的了解。
shiro中有三个重要的概念:

  1. Subject
    主体。可以是一个程序、一个用户,用来表示当前登录的对象。我们通过subject去操作,然后subject委托给Security Manager去执行真正的操作。
  2. Security Manager
    shiro的核心,真正执行操作的地方。
  3. Realm
    安全数据源。指用户的认证授权信息的来源,一般是数据库。
    那么一个大概流程就是这样:
    shiro执行流程

快速上手

数据库设计
基于rabc设计一个简单的权限数据库:
在这里插入图片描述
可以看出三者都是多对多的关系,所以我们需要三个主表:用户表、角色表、权限表,以及三个关联表。
建表:

create table user_info
(
    user_id    int auto_increment
        primary key,
    user_name  varchar(100)  not null comment '用户名',
    login_name varchar(100)  not null comment '登录名',
    password   varchar(100)  not null comment '密码',
    status    int default 0 null comment '状态 1为锁定 0为正常,默认为0'
)
    comment '用户表';

create table role
(
    role_id     int auto_increment
        primary key,
    role_name   varchar(100) not null comment '角色名称',
    description varchar(100) null comment '描述'
)
    comment '角色表';

create table permission
(
    pms_id      int auto_increment
        primary key,
    url         varchar(100) not null comment '接口路径',
    description varchar(100) not null comment '权限说明',
    pms_name    varchar(100) not null comment '权限名称'
)
    comment '权限表';

create table user_role
(
    id         int auto_increment
        primary key,
    user_id    int           not null comment '用户id'
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值