-
Notifications
You must be signed in to change notification settings - Fork 13
Role‐Based Authentication Procedure for RDBMS Ireland Region
Implement a method of role-based authentication for the Ireland DB by identifying and granting admin privileges only to the necessary users, and removing them from others.
- Access to the Ireland DB instance: at least one superuser or root-level access.
- List of current users and their roles: for auditing and validation.
- Stakeholders or team leads: verifying user roles and validating admin needs.
- Policy or standards: any security guidelines or company policy for database access control.
pg_roles is a predefined system catalog view. It is available in every PostgreSQL database by default. It’s a read-only view, so you can query it but not modify it directly.
| Column Name | Description |
|---|---|
| rolname | Name of the role (user/group) |
| rolsuper | Boolean - Is the role a superuser? |
| rolcreaterole | Can the role create other roles? |
| rolcreatedb | Can the role create databases? |
| rolcanlogin | Can the role log in? |
| rolreplication | Can the role initiate replication? |
| rolbypassrls | Can bypass row-level security policies? |
We need a baseline to know who currently has access and assess if it's appropriate. Query the Ireland DB to get a list of all users and their current roles (especially those with admin access).
-- List all roles and their attributes
SELECT
rolname AS role_name,
rolsuper AS is_superuser,
rolcreaterole AS can_create_roles,
rolcreatedb AS can_create_db,
rolreplication AS replication,
rolbypassrls AS bypass_rls
FROM pg_roles
ORDER BY rolname;
One way, PgAdmin, after getting results from the query tool, click download.
People might have admin access for legacy reasons. Direct communication helps validate necessity, avoids confusion, and promotes transparency. Notify team leads and users that a role-based access cleanup is in progress. Share the current list with them. Make use of mail and normal messages.
Ask all users to request admin access if required formally. Include a form or standardized format and convert it into spreadsheet for validation.
- Full Name: full legal name
- Email / Username: database login ID or official email
- Team / Department: e.g., DevOps, Backend, Analytics
- Reason for Admin Access: Why do you need admin-level access? Be specific (e.g., DB schema changes, performance tuning, user management, etc.)
- Access Duration: ☐ Permanent ☐ Temporary If temporary, specify the end date: __________
- Approved By (Team Lead or Manager): Full name and email of the approver
- Additional Comments (Optional): Any other relevant info
- Analyze Requests & Compare With Existing Admins (in Excel):
- Compare the submitted requests with the current admin users. (Step 1 & 3)
- Mark users who no longer need admin rights. (Revoke Admin)
- Mark users who newly requested it and are not on the current list. (Keep Admin, Grant Admin)
Review all requests and role decisions with relevant stakeholders (tech leads, managers). Prevents unauthorized or overprivileged access and provides accountability.
Revoke admin privileges from users not requiring them. Grant admin privileges to approved users only.
To enforce least-privilege access and reduce security risks.
-- Revoke admin:
REVOKE ALL PRIVILEGES ON DATABASE ireland_db FROM user_xyz;
-- Grant admin (as per system setup):
GRANT ALL PRIVILEGES ON DATABASE ireland_db TO user_abc;
– Grant admin rights to user 'user_abc' only if necessary:
ALTER ROLE user_abc WITH SUPERUSER CREATEDB CREATEROLE;
Create roles/groups like db_admin, read_only, analyst, etc., and assign users to those. Easier to manage access levels without updating individual users every time.
Create roles:
-- Admin Role
CREATE ROLE db_admin NOINHERIT;
-- Read-only Role
CREATE ROLE db_readonly NOINHERIT;
-- Grant privileges to the roles
GRANT ALL PRIVILEGES ON DATABASE ireland_db TO db_admin;
GRANT CONNECT ON DATABASE ireland_db TO db_readonly;
Assign Users to Roles:
-- Assign user to role
GRANT db_admin TO user_abc;
GRANT db_readonly TO user_xyz;
Maintain a record of:
- Who has what role
- Approval timestamps
- Review dates
For audit trails and future access reviews.
Sample below:
| Username | Role Assigned | Approved By | Access Type | Review Date |
|-----------|---------------|--------------|-------------|-------------|
| abc_user | db_admin | PallaviC | Permanent | 2025-09-01 |
Set up a quarterly review of all user roles: every 3 or 6 months.
10. Monitor & Audit Log Access
Enable logging and monitor who is accessing what, especially for users with admin roles (postgresql.conf).
logging_collector = on
log_connections = on
log_disconnections = on log_statement = 'ddl'
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h'