(翻译)Spring Security-2.0.x参考文档“安全数据库表结构”

安全数据库表结构

可以为框架采用不同的数据库结构,这个附录为所有功能提供了一种参考形式。你只要为需要的功能部分提供对应的表结构。

这些DDL语句都是对应于HSQLDB数据库的。你可以把它们当作一个指南,参照它,在你使用的数据库中定义表结构。

A.1.User表

UserDetailsService的标准JDBC实现,需要从这些表里读取用户的密码,帐号信息(可用或禁用)和权限(角色)列表。

createtableusers(

usernamevarchar_ignorecase(50)notnullprimarykey,

passwordvarchar_ignorecase(50)notnull,

enabledbooleannotnull);

createtableauthorities(

usernamevarchar_ignorecase(50)notnull,

authorityvarchar_ignorecase(50)notnull,

constraintfk_authorities_usersforeignkey(username)referencesusers(username));

createuniqueindexix_auth_usernameonauthorities(username,authority);;

A.1.1.组权限

SpringSecurity2.0支持了权限分组

createtablegroups(

idbigintgeneratedbydefaultasidentity(startwith0)primarykey,

group_namevarchar_ignorecase(50)notnull);

createtablegroup_authorities(

group_idbigintnotnull,

authorityvarchar(50)notnull,

constraintfk_group_authorities_groupforeignkey(group_id)referencesgroups(id));

createtablegroup_members(

idbigintgeneratedbydefaultasidentity(startwith0)primarykey,

usernamevarchar(50)notnull,

group_idbigintnotnull,

constraintfk_group_members_groupforeignkey(group_id)referencesgroups(id));

A.2.持久登陆(Remember-Me)表

这个表用来保存安全性更高的持久登陆remember-me实现所需要的数据。如果你直接或通过命名空间使用了JdbcTokenRepositoryImpl,你就会需要这些表结构。

createtablepersistent_logins(

usernamevarchar(64)notnull,

seriesvarchar(64)primarykey,

tokenvarchar(64)notnull,

last_usedtimestampnotnull);

A.3.ACL表

这些表对应SpringSecurity的ACL实现。

createtableacl_sid(

idbigintgeneratedbydefaultasidentity(startwith100)notnullprimarykey,

principalbooleannotnull,

sidvarchar_ignorecase(100)notnull,

constraintunique_uk_1unique(sid,principal));

createtableacl_class(

idbigintgeneratedbydefaultasidentity(startwith100)notnullprimarykey,

classvarchar_ignorecase(100)notnull,

constraintunique_uk_2unique(class));

createtableacl_object_identity(

idbigintgeneratedbydefaultasidentity(startwith100)notnullprimarykey,

object_id_classbigintnotnull,

object_id_identitybigintnotnull,

parent_objectbigint,

owner_sidbigint,

entries_inheritingbooleannotnull,

constraintunique_uk_3unique(object_id_class,object_id_identity),

constraintforeign_fk_1foreignkey(parent_object)referencesacl_object_identity(id),

constraintforeign_fk_2foreignkey(object_id_class)referencesacl_class(id),

constraintforeign_fk_3foreignkey(owner_sid)referencesacl_sid(id));

createtableacl_entry(

idbigintgeneratedbydefaultasidentity(startwith100)notnullprimarykey,

acl_object_identitybigintnotnull,ace_orderintnotnull,sidbigintnotnull,

maskintegernotnull,grantingbooleannotnull,audit_successbooleannotnull,

audit_failurebooleannotnull,constraintunique_uk_4unique(acl_object_identity,ace_order),

constraintforeign_fk_4foreignkey(acl_object_identity)referencesacl_object_identity(id),

constraintforeign_fk_5foreignkey(sid)referencesacl_sid(id));

相关推荐