Define DB schema and APIs for UserRoles
See original GitHub issueš Feature
Define the DB schema and APIs for user roles and permissions
NOTE : The delete user API should also call the remove user roles API
Implementation details
DB schema
MySQL
CREATE TABLE IF NOT EXISTS roles (
role VARCHAR(255) NOT NULL,
PRIMARY KEY (role)
);
CREATE TABLE IF NOT EXISTS role_permissions (
role VARCHAR(255) NOT NULL,
permission VARCHAR(255) NOT NULL,
PRIMARY KEY (role, permission),
FOREIGN KEY (role) REFERENCES roles(role) ON DELETE CASCADE
);
CREATE INDEX role_permissions_permission_index ON role_permissions(permission);
CREATE TABLE IF NOT EXISTS user_roles (
user_id VARCHAR(128) NOT NULL,
role VARCHAR(255) NOT NULL,
PRIMARY KEY (user_id, role),
FOREIGN KEY (role) REFERENCES roles (role) ON DELETE CASCADE
);
CREATE INDEX user_roles_role_index ON user_roles(role);
PSQL
CREATE TABLE IF NOT EXISTS roles (
role VARCHAR(255) NOT NULL,
CONSTRAINT roles_pkey PRIMARY KEY (role)
);
CREATE TABLE IF NOT EXISTS role_permissions (
role VARCHAR(255) NOT NULL,
permission VARCHAR(255) NOT NULL,
CONSTRAINT role_permissions_pkey PRIMARY KEY (role, permission),
CONSTRAINT role_permissions_role_fkey FOREIGN KEY (role) REFERENCES roles(role) ON DELETE CASCADE
);
CREATE INDEX role_permissions_permission_index ON role_permissions(permission);
CREATE TABLE IF NOT EXISTS user_roles (
user_id VARCHAR(128) NOT NULL,
role VARCHAR(255) NOT NULL,
CONSTRAINT user_roles_pkey PRIMARY KEY (user_id, role),
CONSTRAINT user_roles_role_fkey FOREIGN KEY (role) REFERENCES roles (role) ON DELETE CASCADE
);
CREATE INDEX user_roles_role_index ON user_roles(role);
Core API spec
Core APIs Psuedo code
- PUT /recipe/user/role: https://app.code2flow.com/oyBIcaFXIf5x
- POST /recipe/user/role/remove: https://app.code2flow.com/HUtwAGGHsJpL
- GET /recipe/user/roles: https://app.code2flow.com/jKKkoUebyxwN
- GET /recipe/role/users: https://app.code2flow.com/Y29CMz2T9ECw
- PUT /recipe/role: https://app.code2flow.com/MqlnBFW8t24n
- GET /recipe/role/permissions: https://app.code2flow.com/a326jJTajsE6
- POST /recipe/role/permissions/remove: https://app.code2flow.com/a08VVz5BZOyC
- GET /recipe/permission/roles: https://app.code2flow.com/vJMgpSsmpURB
- POST /recipe/role/remove: https://app.code2flow.com/PMRh9ehvJ9y9
- GET /recipe/roles: https://app.code2flow.com/HPxvxOUDqQT8
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
What is a Database Schema? - IBM
A database schema defines how data is organized within a relational database; this is inclusive of logical constraints such as, table names,Ā ...
Read more >Overview of Role System ā PostgREST 9.0.0 documentation
PostgREST is designed to keep the database at the center of API security. ... types of roles used by PostgREST, the authenticator, anonymous...
Read more >Using your own database schema and classes with ASP.NET ...
I'm going to walk you through configuring ASP.NET Core Identity to use your own database schema instead of the default tables and columnsĀ ......
Read more >Managing Roles and Permissions - FIWARE Tutorials
Description: The tutorial explains how to create applications, and how to assign roles and permissions to them. It takes the users andĀ ...
Read more >2 Configuring Application Users and Application Roles
About Application User Accounts. Traditional database users own database schemas and can create traditional heavyweight database sessions to those schemas.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks good.
API Spec:
PUT /recipe/user/role:
POST /recipe/user/role/remove:
GET /recipe/user/roles:
GET /recipe/role/users:
PUT /recipe/role:
GET /recipe/role/permissions
POST /recipe/role/permissions/remove:
GET /recipe/permission/roles:
POST /recipe/role/remove
GET /recipe/roles: