forked from morenoh149/postgresDBSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9946b62
commit dcbd601
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Create Tables | ||
*/ | ||
drop table rbac_permissions, rbac_rolepermissions, rbac_roles, rbac_userroles; | ||
|
||
create table if not exists rbac_permissions ( | ||
id serial primary key, | ||
lft integer not null, | ||
rght integer not null, | ||
title text not null, | ||
description text not null | ||
); | ||
create index on rbac_permissions (lft); | ||
create index on rbac_permissions (rght); | ||
create index on rbac_permissions (title); | ||
|
||
create table if not exists rbac_rolepermissions ( | ||
role_id integer not null, | ||
permission_id integer not null, | ||
assignment_date timestamptz not null, | ||
primary key (role_id, permission_id) | ||
); | ||
|
||
create table if not exists rbac_roles ( | ||
id serial primary key, | ||
lft integer not null, | ||
rght integer not null, | ||
title varchar not null, | ||
description text not null | ||
); | ||
create index on rbac_roles (lft); | ||
create index on rbac_roles (rght); | ||
create index on rbac_roles (title); | ||
|
||
create table if not exists rbac_userroles ( | ||
user_id integer not null, | ||
role_id integer not null, | ||
assignment_date timestamptz not null, | ||
primary key (user_id, role_id) | ||
); | ||
|
||
/* | ||
* Insert Initial Table Data | ||
*/ | ||
insert into rbac_permissions (id, lft, rght, title, description) | ||
values (1, 0, 1, 'root', 'root'); | ||
|
||
insert into rbac_rolepermissions (role_id, permission_id, assignment_date) | ||
values (1, 1, current_timestamp); | ||
|
||
insert into rbac_roles (id, lft, rght, title, description) | ||
values (1, 0, 1, 'root', 'root'); | ||
|
||
insert into rbac_userroles (user_id, Role_id, assignment_date) | ||
values (1, 1, current_timestamp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Role Based Access Control | ||
|
||
An implementation of [NIST level 2 RBAC](http://csrc.nist.gov/groups/SNS/rbac/) | ||
Hierarchical RBAC | ||
|
||
Work in progress, contributions welcome |
Binary file not shown.