Skip to content

Commit

Permalink
initial rbac schema
Browse files Browse the repository at this point in the history
  • Loading branch information
morenoh149 committed Feb 9, 2016
1 parent 9946b62 commit dcbd601
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ A collection of sample databases for PostgreSQL.
* Pagila - Movie rental database with actors, ratings, payments, etc.
* USDA - food database
* World - city, country, language for the world
* Role Based Access Control - authentication solution
55 changes: 55 additions & 0 deletions role-based-access-control/rbac.sql
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);
6 changes: 6 additions & 0 deletions role-based-access-control/readme.md
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.

0 comments on commit dcbd601

Please sign in to comment.