spring-security--基础--5.1--ACL--介绍

spring-security–基础–5.1–ACL–介绍


代码位置

https://gitee.com/DanShenGuiZu/learnDemo/tree/master/spring-security-learn

1、介绍

  1. ACL(访问控制列表):是附加到对象的权限列表
  2. ACL:指定在给定对象上授予哪些标识哪些操作
  3. 是支持域对象安全性的Spring组件。
  4. 可以为单个域对象上的特定用户/角色定义权限,而不是在典型的每个操作级别上全面定义权限。

1.1、理解:不同的用户/角色对每个特定对象具有不同的权限

举例:对通知消息

  1. 管理员角色的用户:
    1. 消息范围:所有消息
    2. 操作
      1. 可读
      2. 可写
  2. 普通用户
    1. 消息范围:特定的消息
    2. 操作
      1. 可读
      2. 不可写
  3. "编辑者"角色的用户
    1. 消息范围:特定的消息
    2. 操作
      1. 可读
      2. 可写

2、ACL数据库

要使用Spring Security ACL,我们需要在数据库中创建四个强制性表。

2.1、ER图

在这里插入图片描述

2.2、表说明


 
set names utf8mb4;
set foreign_key_checks = 0; 
 
drop table if exists `acl_class`;
create table `acl_class`  (
  `id` bigint(0) not null comment '主键id',
  `class` varchar(100)  not null comment '安全域对象的类名,例如:com.hd.rcugrc.menu.menuitem',
  primary key (`id`) using btree,
  unique index `ind_hd_class`(`class`) using btree
) engine = innodb  comment = '存储域对象的类名称' row_format = dynamic;

 
drop table if exists `acl_sid`;
create table `acl_sid`  (
  `id` bigint(0) not null comment '主键id',
  `principal` smallint(0) not null comment '0或1,访问主体的类型;0:表示相应的sid是主体(用户,例如hdadmin);1:表示相应的sid是授权机构(角色,部门,例如role_admin,role_user,GROUP_25369…)',
  `sid` varchar(100)  not null comment '安全标识符,代表安全身份,也就是访问主体,这里可能是用户账号或部门编码或角色编码',
  primary key (`id`) using btree,
  unique index `ind_hd_sid`(`sid`, `principal`) using btree
) engine = innodb  comment = '安全标识符表,用于标识访问主体,该表允许我们通用地标识系统中的任何原理或权限' row_format = dynamic;


drop table if exists `acl_object_identity`;
create table `acl_object_identity`  (
  `id` bigint(0) not null comment '主键id',
  `object_id_class` bigint(0) not null comment '定义域对象类,链接到acl_class表',
  `object_id_identity` bigint(0) not null comment '取决于类,域对象可以存储在许多表中。 因此,此字段存储目标对象的主键',
  `parent_object` bigint(0) null default null comment '指定此对象标识的父对象',
  `owner_sid` bigint(0) null default null comment '对象所有者的id,链接到acl_sid表,这里是acl_sid表的sid对应表的主键id,比如sid是用户账号,那么这里是用户表主键id',
  `entries_inheriting` smallint(0) not null comment '此对象的acl条目是否从父对象继承(acl条目在acl_entry表中定义)',
  primary key (`id`) using btree,
  unique index `udx_hd_obj_id_oid`(`object_id_class`, `object_id_identity`) using btree,
  index `ind_hd_obj_id_oclass`(`object_id_class`) using btree,
  index `ind_hd_obj_id_sid`(`owner_sid`) using btree,
  index `ind_hd_obj_id_parent`(`parent_object`) using btree,
  CONSTRAINT `acl_obj_id_ibfk_1` FOREIGN KEY (`OBJECT_ID_CLASS`) REFERENCES `acl_class` (`ID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `acl_obj_id_ibfk_2` FOREIGN KEY (`PARENT_OBJECT`) REFERENCES `acl_object_identity` (`ID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `acl_obj_id_ibfk_3` FOREIGN KEY (`OWNER_SID`) REFERENCES `acl_sid` (`ID`) ON DELETE RESTRICT ON UPDATE RESTRICT
) engine = innodb  comment = '域对象表,存储每个唯一域对象的信息' row_format = dynamic;



drop table if exists `acl_entry`;
create table `acl_entry`  (
  `id` bigint(0) not null comment '主键id',
  `acl_object_identity` bigint(0) not null comment '指定对象标识,链接到acl_object_identity表的主键id',
  `ace_order` int(0) not null comment '当前条目在相应对象标识的acl条目列表中的顺序',
  `sid` bigint(0) not null comment '授予或拒绝许可的目标sid,链接到acl_sid表',
  `mask` int(0) not null comment '整数位掩码,代表被授予或拒绝的实际权限',
  `granting` smallint(0) not null comment '授予:值1:表示授予,值0:表示拒绝',
  `audit_success` smallint(0) not null comment '用于审核',
  `audit_failure` smallint(0) not null comment '用于审核',
  primary key (`id`) using btree,
  index `ind_hd_entry_oid`(`acl_object_identity`) using btree,
  index `ind_hd_entry_sid`(`sid`) using btree,
  constraint `hd_entry_ibfk_1` foreign key (`acl_object_identity`) references `acl_object_identity` (`id`) on delete restrict on update restrict,
  constraint `hd_entry_ibfk_2` foreign key (`sid`) references `acl_sid` (`id`) on delete restrict on update restrict
) engine = innodb  comment = 'ACL条目表,存储将单个权限分配给对象标识上的每个sid' row_format = dynamic;

  
set foreign_key_checks = 1;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值