Privilege Management System
Overview
TacNode implements a PostgreSQL-compatible privilege management system with optimizations and extensions for cloud-native architecture. This document provides a comprehensive guide to TacNode's privilege management mechanisms and key differences from standard PostgreSQL.
Core Features:
- Database-Level User Management: Independent user systems for each database instance
- Role-Based Access Control: Flexible role hierarchy with inheritance capabilities
- Enterprise Integration: Seamless cloud account integration with database users
- PostgreSQL Compatibility: Standard SQL privilege commands and permission models
- Security Best Practices: Built-in support for principle of least privilege
Key Differences from PostgreSQL
1. User Management Scope
PostgreSQL:
- Users are global across all database instances
- A user created in one PostgreSQL instance can be used in all databases
TacNode:
- Each database requires independent user creation
- User management is database-scoped, with users isolated between different databases
2. Cloud Platform Integration
PostgreSQL:
- No platform-level account concept
- User management is entirely database-level
TacNode:
- Integrated cloud service with platform account system
- Cloud accounts are automatically added to databases when creating instances
- Mapping relationship exists between cloud accounts and database users
TacNode Privilege Architecture
TacNode's privilege system consists of several hierarchical layers:
1. Global User Management
Global users are registered at the TacNode platform level and can use unified identity across multiple database instances.
2. Database User Management
Each database instance can independently manage local users and roles, visible only within the current database.
3. Role-Based Access Control
Implements fine-grained privilege control through predefined and custom roles.
User and Role Types
Global User
- Visibility: Visible across the entire TacNode platform
- Reference: Can be referenced in any database
- Password Management: Stored in platform services, cannot be managed via SQL
- Authorization: Cannot be granted to other users or roles (only serves as final privilege recipient)
Local User
- Visibility: Only visible within the current database
- Password Management: Can set passwords and manage via SQL
- Authorization: Can be granted to role groups and serve as role group members
Local Role
- Visibility: Only visible within the current database
- Password: No password attribute
- Purpose: Primarily used for privilege grouping and role inheritance
Practical Implementation Scenarios
Scenario 1: Enterprise-Grade Privilege Management
Business Requirements: An e-commerce enterprise needs different data access privileges for team members:
- Data Analysts: Read-only access to specific business data for generating reports
- BI Reporting System: Read access to source data and write access to reporting data for automated report generation
- Database Administrators: Full access privileges for daily maintenance and security management
Implementation Solution:
First, create specialized roles for different responsibilities and assign appropriate privileges:
Assign read-only privileges to the data analyst role for all tables in the public schema:
Set default privileges so the data analyst role has read-only access to future tables:
Create a dedicated reporting schema for the BI system role and assign appropriate privileges:
Set default privileges for the BI system role on future objects:
Create specific user accounts (note: these users must be registered on the TacNode platform first):
Assign roles to corresponding users:
Privilege Verification:
After configuration, verify that privileges are correctly set:
Scenario 2: Simplified Privilege Model
Business Requirements: Startups or small teams need to quickly establish a privilege management system while simplifying privilege management complexity:
- Developers: Development environment read-write privileges for application development and testing
- Data Analysts: Read-only privileges for data analysis and report creation
- Administrators: Complete privileges including user management and privilege assignment capabilities
Implementation Solution:
First, create four basic roles corresponding to different privilege levels:
Assign corresponding data access privileges to these roles:
Set default privileges for future objects:
Establish inheritance relationships between roles so higher-level roles automatically inherit lower-level role privileges:
Assign management privileges for other roles to administrator role:
Privilege Verification:
After configuration, verify that privileges are correctly set:
Privilege Verification
After completing privilege configuration, verifying successful authorization is crucial for ensuring system security. Proper verification methods can confirm whether users and roles have expected access privileges.
Verifying User Privileges
1. Connect to Database Using psql
2. Check Current User Privileges
After connecting to the database, execute the following SQL commands to view current user privileges:
3. Check Object Privileges
Verifying Role Privileges
1. View Role Definitions
2. View Role Inheritance Relationships
3. View Default Privileges
Best Practices
1. Principle of Least Privilege
Only grant users the minimum privileges required to complete their work, avoiding over-authorization.
2. Role Reuse
Create common roles to avoid setting privileges individually for each user, facilitating subsequent maintenance.
3. Regular Auditing
Regularly review user privilege assignments and promptly clean up unnecessary privileges.
4. Security Auditing
Record privilege change logs for security auditing and issue tracking.
5. Privilege Verification Best Practices
- Regular Verification: Periodically check privilege configurations to ensure compliance with security requirements
- Minimum Privilege Verification: Verify users have only the minimum privileges needed to complete their work
- Role Inheritance Verification: Verify role inheritance relationships are correctly configured
- Default Privilege Verification: Verify default privileges are correctly applied to newly created objects
- Audit Log Review: Check audit logs for privilege-related operations
PostgreSQL Compatibility
Although TacNode differs from PostgreSQL in user management scope and cloud platform integration, it maintains high compatibility in the following areas:
- SQL Syntax: Commands like
CREATE USER
,CREATE ROLE
,GRANT
,REVOKE
have identical syntax to PostgreSQL - Privilege Model: Privilege types and behaviors like
SELECT
,INSERT
,UPDATE
,DELETE
are identical to PostgreSQL - Role Inheritance: Role inheritance mechanisms and privilege transfer methods are consistent with PostgreSQL
- Predefined Roles: Predefined roles like
pg_read_all_data
,pg_write_all_data
are identical to PostgreSQL
Troubleshooting
Common Issues
- User Not Registered Error: Ensure users are registered on the TacNode platform before creating database users
- Insufficient Privileges Error: Check whether users have the privileges required to perform operations
- Connection Rejected Error: Confirm whether users have database connection privileges
Troubleshooting Steps
- Confirm whether users are registered on the platform
- Check whether users have been correctly authorized to appropriate roles
- Verify whether corresponding users have been created in the database
- Check security group and network configuration correctness
Advanced Configuration Examples
Multi-Environment Privilege Separation
Application-Specific Privilege Management
This comprehensive privilege management system ensures that TacNode databases maintain enterprise-grade security while providing flexibility for various organizational structures and security requirements.