Appendix A. 安全数据库表结构
可以为框架采用不同的数据库结构,这个附录为所有功能提供了一种参考形式。 你只要为需要的功能部分提供对应的表结构。
这些DDL语句都是对应于HSQLDB数据库的。 你可以把它们当作一个指南,参照它,在你使用的数据库中定义表结构。
UserDetailsService
的标准JDBC实现(JdbcDaoImpl
),需要从这些表里读取用户的密码,帐号信息(可用或禁用)和权限(角色)列表。
create table users( username varchar_ignorecase(50) not null primary key, password varchar_ignorecase(50) not null, enabled boolean not null); create table authorities ( username varchar_ignorecase(50) not null, authority varchar_ignorecase(50) not null, constraint fk_authorities_users foreign key(username) references users(username)); create unique index ix_auth_username on authorities (username,authority);
Spring Security 2.0在JdbcDaoImpl
中支持了权限分组。 如果启用了权限分组功能,对应的数据库结果如下所示:
create table groups ( id bigint generated by default as identity(start with 0) primary key, group_name varchar_ignorecase(50) not null); create table group_authorities ( group_id bigint not null, authority varchar(50) not null, constraint fk_group_authorities_group foreign key(group_id) references groups(id)); create table group_members ( id bigint generated by default as identity(start with 0) primary key, username varchar(50) not null, group_id bigint not null, constraint fk_group_members_group foreign key(group_id) references groups(id));
这个表用来保存安全性更高的持久登陆remember-me实现所需要的数据。 如果你直接或通过命名空间使用了JdbcTokenRepositoryImpl
,你就会需要这些表结构。
create table persistent_logins ( username varchar(64) not null, series varchar(64) primary key, token varchar(64) not null, last_used timestamp not null);
这里有四个表被Spring Security用来实现 ACL。
-
acl_sid
保存被ACL系统分配的安全标示符。 它们可能是唯一的实体或可能分配给多个实体的权限。 -
acl_class
定义ACL可以处理的实体类型。class
列保存了对象的Java类名。 -
acl_object_identity
保存值得那个领域对象昂的对象标示定义。 -
acl_entry
保存ACL权限,分配给一个特定的对象标示和安全标示。
假设数据库会自动生成主键作为每个标示。 JdbcMutableAclService
必须可以获得这些,当创建了一个新的 acl_sid
或acl_class
表中的数据。 它有两个属性可以定义需要的SQL来获得这些数据, classIdentityQuery
和sidIdentityQuery
。 这两个属性的默认值是call identity()
。
默认的表结构可以工作在内嵌的HSQLDB中,可以在框架内用作单元测试。
create table acl_sid ( id bigint generated by default as identity(start with 100) not null primary key, principal boolean not null, sid varchar_ignorecase(100) not null, constraint unique_uk_1 unique(sid,principal) ); create table acl_class ( id bigint generated by default as identity(start with 100) not null primary key, class varchar_ignorecase(100) not null, constraint unique_uk_2 unique(class) ); create table acl_object_identity ( id bigint generated by default as identity(start with 100) not null primary key, object_id_class bigint not null, object_id_identity bigint not null, parent_object bigint, owner_sid bigint not null, entries_inheriting boolean not null, constraint unique_uk_3 unique(object_id_class,object_id_identity), constraint foreign_fk_1 foreign key(parent_object) references acl_object_identity(id), constraint foreign_fk_2 foreign key(object_id_class) references acl_class(id), constraint foreign_fk_3 foreign key(owner_sid) references acl_sid(id) ); create table acl_entry ( id bigint generated by default as identity(start with 100) not null primary key, acl_object_identity bigint not null,ace_order int not null,sid bigint not null, mask integer not null,granting boolean not null,audit_success boolean not null, audit_failure boolean not null, constraint unique_uk_4 unique(acl_object_identity,ace_order), constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), constraint foreign_fk_5 foreign key(sid) references acl_sid(id) );
create table acl_sid( id bigserial not null primary key, principal boolean not null, sid varchar(100) not null, constraint unique_uk_1 unique(sid,principal)); create table acl_class( id bigserial not null primary key, class varchar(100) not null, constraint unique_uk_2 unique(class)); create table acl_object_identity( id bigserial primary key, object_id_class bigint not null, object_id_identity bigint not null, parent_object bigint, owner_sid bigint, entries_inheriting boolean not null, constraint unique_uk_3 unique(object_id_class,object_id_identity), constraint foreign_fk_1 foreign key(parent_object) references acl_object_identity(id), constraint foreign_fk_2 foreign key(object_id_class) references acl_class(id), constraint foreign_fk_3 foreign key(owner_sid) references acl_sid(id)); create table acl_entry( id bigserial primary key, acl_object_identity bigint not null, ace_order int not null, sid bigint not null, mask integer not null, granting boolean not null, audit_success boolean not null, audit_failure boolean not null, constraint unique_uk_4 unique(acl_object_identity,ace_order), constraint foreign_fk_4 foreign key(acl_object_identity) references acl_object_identity(id), constraint foreign_fk_5 foreign key(sid) references acl_sid(id));
你需要把classIdentityQuery
和 sidIdentityQuery
两个 JdbcMutableAclService
的属性设置成下面的值:
-
select currval(pg_get_serial_sequence('acl_class', 'id'))
-
select currval(pg_get_serial_sequence('acl_sid', 'id'))
相关推荐
首先说声抱歉,上次发布的项目不是源代码。我没看清楚就发布了。...(5)项目采用的是5张数据表结构。前台及后台各采用了5张数据库表。当然你也可以进行修改后合并。 (6)数据库采用MYSQL 备份文件在src文件夹下。
该资源是springsecurity+oauth2+jwt实现的单点登录demo,模式为授权码模式,...应用数据存在内存中或者存在数据库中(附带数据库表结构),token存储分为数据库或者Redis。demo包含服务端和客户端,可直接运行测试。
2. 数据库设计:设计数据库表结构,包括用户表、角色表、权限表等。 3. 后端开发: - 使用Spring Boot搭建后端框架。 - 集成Spring Security,配置安全认证相关的配置,如登录认证、访问权限控制等。 - 实现用户...
默认情况下,Spring Security通过4个SQL表管理ACL,这些SQL表在每次访问域对象时在查找时连接在一起。 虽然它在内部使用缓存来尽可能减少到数据库的往返,但将数据以非平面结构存储在 NoSQL 数据库中可以进一步帮助...
说明: 1、附件使用的MySQL数据的sql文件 2、sql主要包含Oauth2.0使用的数据源数据库库表及用户管理系统库表 3、使用Navicat for mySql可一键恢复数据库库表结构
低代码开发脚手架项目简介基于SpringBoot 2.3.2 + Mybatis-Plus + SpringSecurity + JWT 的前后分离后台管理系统前端仓库地址:项目特性开箱即用,引入starter依赖后即可启动高效开发,只需要定义实体与库表,...
设计数据库表结构,包括患者表、医生表、挂号表、门诊表、住院表、药品表、检查检验表、收费结算表等。创建相应的SQL脚本以便后续使用。 实体类创建: 根据数据库表结构,创建对应的实体类。 数据访问层(DAO): ...
information_schema:提供关于所有数据库、表、列、索引等元数据信息,是查询数据库结构的标准接口。 mysql:存储MySQL自身的系统信息,如用户权限、服务器配置、事件调度等。 performance_schema:自MySQL 5.5...
初始化数据库:找到目录:/ spring-batch-admin-backend / src / main / db,里面有两个文件,一个是数据库创建脚本,一个是表结构+数据的脚本,先执行创建库的,如果想在已经存在的库里面运行程序,可以省略这一步...
Spring Security: Spring Security是一个安全的框架,它提供了认证和授权功能,用于保护Web应用程序。 MyBatis: MyBatis是一个流行的持久层框架,它简化了数据库访问。它允许使用SQL语句来访问数据库,并将SQL语句...
程序的结构分为表现层(Controller)、业务层(Service)、数据层(Dao),包括权限授权、分页查询、日志记录,订单及产品查询,授权管理等功能 入门级DEMO 博客链接: 技术点: Spring IOC & DI(控制反转和依赖注入) ...
api_sync_mongo 这是一个具有基本REST结构的项目,旨在同步来自移动设备的数据并生成系统日志,所使用的技术包括: -Framework Spring Boot 2,-MongoDB,-Spring Security,-JWT,-Swagger
权限管理:SpringSecurity, 跨域:cros 支付:微信扫描 短信验证:阿里大于 密码加密:BCrypt 富文本:KindEditor 事务:声明式事务 任务调度:spring task 所有的技术,都可能涉及到为什么用?怎么用?用的过程中...
数据库设计合理,表结构清晰,保证了数据的一致性和完整性。 此外,该项目采用了Maven或Gradle作为项目构建工具,便于依赖管理和项目构建。通过Docker容器化技术,可以轻松实现应用的部署和运行。 总而言之,这个...
entity:存放实体类,对应数据库中的表结构。util:存放工具类,提供一些常用方法。resources:存放静态资源,如HTML、CSS、JavaScript文件等。数据库设计:该项目使用了MySQL数据库,设计了多个表来存储用户信息、...
在第二次作业的基础上,增加SpringSecurity框架,并在数据库创建用户表(users)和权限表(roles),用户表和权限表之间是多对多关系。权限类型有教师权限、管理员权限,教师权限仅可查看所有的学生选课,管理员权限可...
表结构定义在resources/sql-script/schema.sql,表数据定义在resources/sql-script/data.sql,所以运行项目时不需要本地先安装数据库软件。Redisson使用了redis, 因此配置文件需要正确填写redis服务器地址.可以通过...
- 执行db/mysql.sql文件,初始化数据【按需导入表结构及数据】 - 导入仓库、仓位、设备数据,请按照表结构导入。 - 修改renren-admin模块application-dev.yml文件,更新MySQ ## 项目备注 1、该资源内项目代码都经过...
数据库设计:提供海鲜市场系统中商品信息、用户信息、订单信息等核心数据的数据库表结构设计,以及关系映射和索引优化策略。接口设计:详细定义系统内各模块之间交互的API接口,包括请求类型、参数列表、响应格式等...
6. **安全性设计**:后端采用Spring Security进行安全控制,确保了用户认证和授权的安全性,保护用户的财务数据不被未授权访问。 7. **前后端整合**:虽然前端使用JSP,但通过与后端SSM框架整合,可实现动态内容展示...