This document covers user management and Role-Based Access Control (RBAC) commands in SyndrDB. These commands handle user creation, permission grants, role assignments, and access control.
SyndrDB implements a comprehensive Role-Based Access Control (RBAC) system with the following components:
The RBAC system consists of six interconnected bundles in the primary database:
| Bundle | Purpose | Key Fields |
|---|---|---|
| Users | User accounts | UserID, Name, PasswordHash, IsActive, IsLockedOut |
| Permissions | Permission definitions | PermissionID, Name |
| Roles | Role definitions | RoleID, Name |
| UserPermissions | Direct user permissions (junction) | UserID, PermissionID |
| UserRoles | User role assignments (junction) | UserID, RoleID |
| RolesPermissions | Role permission mappings (junction) | RoleID, PermissionID |
Users can have permissions through two paths:
GRANT "permission" TO USERGRANT ROLE "role" TO USERWhen checking if a user has a permission, SyndrDB checks both paths.
Creates a new user account with password authentication.
CREATE USER "username" WITH PASSWORD 'password';
| Component | Description | Required |
|---|---|---|
| username | Unique username for the account | ✅ Yes |
| password | Password for authentication | ✅ Yes |
Usernames must follow these rules:
_), hyphens (-)Passwords must meet these requirements:
') or double (") quotes-- Create user with simple password
CREATE USER "alice" WITH PASSWORD 'SecurePass123!';
-- Response: User 'alice' created successfully with default 'Data-Reader' role.
-- Create user with double-quoted password
CREATE USER "bob" WITH PASSWORD "MyP@ssw0rd";
-- Response: User 'bob' created successfully with default 'Data-Reader' role.
-- Create admin user (will need permissions granted separately)
CREATE USER "admin_sarah" WITH PASSWORD 'AdminP@ss2024!';
-- Grant admin permissions
GRANT "Admin" TO USER "admin_sarah";
-- Create test users
CREATE USER "dev_tester1" WITH PASSWORD 'TestPass123!';
CREATE USER "dev_tester2" WITH PASSWORD 'TestPass123!';
CREATE USER "readonly_user" WITH PASSWORD 'ReadOnly999!';
SyndrDB uses Argon2id for password hashing:
| Error | Cause | Solution |
|---|---|---|
username contains invalid characters |
Invalid username format | Use only letters, numbers, _, - |
username must start with a letter |
Username starts with number | Start username with letter |
username too long |
More than 64 characters | Shorten username |
password too short |
Less than 8 characters | Use longer password |
password too long |
More than 128 characters | Use shorter password |
user already exists |
Username already taken | Choose different username |
failed to create user |
System error | Check logs, retry |
⚠️ Password Storage:
⚠️ Password Transmission:
⚠️ Account Security:
✅ DO:
❌ DON'T:
-- Step 1: Create the user
CREATE USER "data_analyst" WITH PASSWORD 'AnalystP@ss2024!';
-- Response: User 'data_analyst' created successfully with default 'Data-Reader' role.
-- Step 2: Grant additional permissions as needed
GRANT ROLE "Data-Writer" TO USER "data_analyst";
-- Response: Role 'Data-Writer' granted to user 'data_analyst' successfully.
-- Step 3: Grant specific permissions
GRANT "Admin" TO USER "data_analyst";
-- Response: Permission 'Admin' granted to user 'data_analyst' successfully.
-- User now has:
-- - Data-Reader role (automatic)
-- - Data-Writer role (granted)
-- - Admin permission (granted directly)
-- Create team of users with different access levels
-- Read-only analysts
CREATE USER "analyst1" WITH PASSWORD 'ReadP@ss123!';
CREATE USER "analyst2" WITH PASSWORD 'ReadP@ss456!';
-- Both automatically have Data-Reader role
-- Data writers
CREATE USER "writer1" WITH PASSWORD 'WriteP@ss789!';
GRANT ROLE "Data-Writer" TO USER "writer1";
-- Database administrators
CREATE USER "dba_admin" WITH PASSWORD 'DbaP@ss2024!';
GRANT ROLE "Dbo" TO USER "dba_admin";
-- Application service account
CREATE USER "app_backend" WITH PASSWORD 'AppS3rv1c3!2024';
GRANT ROLE "Data-Writer" TO USER "app_backend";
GRANT "Write" TO USER "app_backend";
Grant commands assign permissions and roles to users. Permissions can be granted directly or inherited through roles.
Grants a specific permission directly to a user.
GRANT "permission_name" TO USER "username";
| Component | Description | Required |
|---|---|---|
| permission_name | Name of the permission to grant | ✅ Yes |
| username | Username to receive the permission | ✅ Yes |
If the permission doesn't exist, it will be automatically created when granted. This allows for flexible, custom permissions.
-- Grant Read permission
GRANT "Read" TO USER "alice";
-- Response: Permission 'Read' granted to user 'alice' successfully.
-- Grant Write permission
GRANT "Write" TO USER "bob";
-- Response: Permission 'Write' granted to user 'bob' successfully.
-- Grant Admin permission
GRANT "Admin" TO USER "sarah";
-- Response: Permission 'Admin' granted to user 'sarah' successfully.
-- Grant custom permission (will be created automatically)
GRANT "ReportGeneration" TO USER "analyst";
-- Response: Permission 'ReportGeneration' granted to user 'analyst' successfully.
-- Grant another custom permission
GRANT "DataExport" TO USER "exporter";
-- Response: Permission 'DataExport' granted to user 'exporter' successfully.
-- Grant several permissions to same user
GRANT "Read" TO USER "developer";
GRANT "Write" TO USER "developer";
GRANT "Delete" TO USER "developer";
| Error | Cause | Solution |
|---|---|---|
user not found |
Username doesn't exist | Create user first with CREATE USER |
permission already granted |
Permission already assigned | No action needed |
internal error |
System error | Check logs, verify database integrity |
✅ DO:
❌ DON'T:
When to use direct permission grants:
When to use role grants:
-- Create user
CREATE USER "report_user" WITH PASSWORD 'ReportP@ss!';
-- Grant direct permissions for custom access
GRANT "ReportGeneration" TO USER "report_user";
GRANT "ReportScheduling" TO USER "report_user";
GRANT "ReportExport" TO USER "report_user";
-- Also grant Read permission for data access
GRANT "Read" TO USER "report_user";
-- User now has:
-- - Data-Reader role (automatic on user creation)
-- - Read permission (granted directly)
-- - ReportGeneration permission (custom, auto-created)
-- - ReportScheduling permission (custom, auto-created)
-- - ReportExport permission (custom, auto-created)
Grants a role to a user, providing all permissions associated with that role.
GRANT ROLE "role_name" TO USER "username";
| Component | Description | Required |
|---|---|---|
| role_name | Name of the role to grant | ✅ Yes |
| username | Username to receive the role | ✅ Yes |
SyndrDB includes several built-in roles (see Pre-defined Roles & Permissions):
| Role | Description |
|---|---|
| Data-Reader | Read-only access to data (default for new users) |
| Data-Writer | Read and write access to data |
| Dbo | Database owner - full database control |
| Admin | System administrator - full system control |
-- Grant Data-Writer role
GRANT ROLE "Data-Writer" TO USER "alice";
-- Response: Role 'Data-Writer' granted to user 'alice' successfully.
-- Grant Dbo (Database Owner) role
GRANT ROLE "Dbo" TO USER "db_admin";
-- Response: Role 'Dbo' granted to user 'db_admin' successfully.
-- Grant Admin role
GRANT ROLE "Admin" TO USER "system_admin";
-- Response: Role 'Admin' granted to user 'system_admin' successfully.
-- User can have multiple roles
CREATE USER "power_user" WITH PASSWORD 'PowerP@ss!';
-- Automatically has Data-Reader
GRANT ROLE "Data-Writer" TO USER "power_user";
-- Now has Data-Reader + Data-Writer
GRANT ROLE "Dbo" TO USER "power_user";
-- Now has Data-Reader + Data-Writer + Dbo
-- Analysts (read-only) - already have Data-Reader by default
CREATE USER "analyst1" WITH PASSWORD 'Pass1!';
CREATE USER "analyst2" WITH PASSWORD 'Pass2!';
-- Developers (read-write)
CREATE USER "dev1" WITH PASSWORD 'Pass3!';
GRANT ROLE "Data-Writer" TO USER "dev1";
CREATE USER "dev2" WITH PASSWORD 'Pass4!';
GRANT ROLE "Data-Writer" TO USER "dev2";
-- Database administrators (full control)
CREATE USER "dba1" WITH PASSWORD 'Pass5!';
GRANT ROLE "Dbo" TO USER "dba1";
When a role is granted, the user immediately gains all permissions from that role:
-- Example: Data-Writer role includes Read and Write permissions
GRANT ROLE "Data-Writer" TO USER "alice";
-- Alice now has:
-- - Read permission (from Data-Writer role)
-- - Write permission (from Data-Writer role)
-- - Any permissions from Data-Reader role (default)
| Error | Cause | Solution |
|---|---|---|
user not found |
Username doesn't exist | Create user first with CREATE USER |
role not found |
Role doesn't exist | Use valid role name (see pre-defined roles) |
role already granted |
User already has this role | No action needed |
internal error |
System error | Check logs, verify database integrity |
✅ DO:
❌ DON'T:
Users can have multiple roles, and permissions are additive:
CREATE USER "hybrid_user" WITH PASSWORD 'Hybrid!23';
-- Grant multiple roles
GRANT ROLE "Data-Writer" TO USER "hybrid_user";
GRANT ROLE "Dbo" TO USER "hybrid_user";
-- User now has permissions from:
-- - Data-Reader (default)
-- - Data-Writer (granted)
-- - Dbo (granted)
-- Total permissions are the union of all role permissions
-- Setup: Create users for different roles
-- 1. Read-only analyst
CREATE USER "analyst_jane" WITH PASSWORD 'AnalystP@ss!';
-- Has Data-Reader role automatically
-- Can: Read data
-- Cannot: Write, Delete, Admin operations
-- 2. Data entry specialist
CREATE USER "dataentry_tom" WITH PASSWORD 'DataP@ss!';
GRANT ROLE "Data-Writer" TO USER "dataentry_tom";
-- Has: Data-Reader + Data-Writer
-- Can: Read and Write data
-- Cannot: Delete bundles, Admin operations
-- 3. Database administrator
CREATE USER "dba_sarah" WITH PASSWORD 'DbaP@ss!';
GRANT ROLE "Dbo" TO USER "dba_sarah";
-- Has: Data-Reader + Dbo
-- Can: Full database control (create bundles, manage schema)
-- Cannot: System-level admin operations
-- 4. System administrator
CREATE USER "sysadmin_mike" WITH PASSWORD 'SysP@ss!';
GRANT ROLE "Admin" TO USER "sysadmin_mike";
-- Has: Data-Reader + Admin
-- Can: Everything (full system control)
-- 5. Power user with multiple roles
CREATE USER "poweruser_alex" WITH PASSWORD 'PowerP@ss!';
GRANT ROLE "Data-Writer" TO USER "poweruser_alex";
GRANT ROLE "Dbo" TO USER "poweruser_alex";
-- Has: Data-Reader + Data-Writer + Dbo
-- Can: Read, Write, and manage database schema
-- Cannot: System-level admin (no Admin role)
SyndrDB includes several pre-defined roles with associated permissions. These roles are automatically created during system initialization.
Description: Read-only access to database content
Automatically Granted: ✅ Yes - to all new users
Permissions Included:
Read - Read documents from bundlesSelect - Execute SELECT queriesShowBundles - List available bundlesTypical Users:
Example:
-- Data-Reader is automatically granted on user creation
CREATE USER "viewer" WITH PASSWORD 'ViewP@ss!';
-- User 'viewer' can now read data but cannot modify anything
Description: Read and write access to database content
Automatically Granted: ❌ No - must be explicitly granted
Permissions Included:
Write - Write documents to bundlesUpdate - Update existing documentsDelete - Delete documents from bundlesInsert - Add new documentsTypical Users:
Example:
CREATE USER "app_backend" WITH PASSWORD 'AppP@ss!';
GRANT ROLE "Data-Writer" TO USER "app_backend";
-- User can now read and write data
Description: Full control over database schema and structure
Automatically Granted: ❌ No - must be explicitly granted
Permissions Included:
CreateBundle - Create new bundlesAlterBundle - Modify bundle structureDropBundle - Delete bundlesCreateIndex - Create indexesDropIndex - Delete indexesManageRelationships - Create/modify bundle relationshipsTypical Users:
Example:
CREATE USER "db_admin" WITH PASSWORD 'DbAdminP@ss!';
GRANT ROLE "Dbo" TO USER "db_admin";
-- User can now manage database schema
Description: Full system administration privileges
Automatically Granted: ❌ No - must be explicitly granted
Permissions Included:
CreateDatabase - Create new databasesDropDatabase - Delete databasesCreateUser - Create user accountsGrantPermission - Grant permissions to usersGrantRole - Grant roles to usersManageBackups - Create and restore backupsManageMigrations - Run database migrationsSystemConfiguration - Modify system settingsTypical Users:
Example:
CREATE USER "sysadmin" WITH PASSWORD 'SysAdminP@ss!';
GRANT ROLE "Admin" TO USER "sysadmin";
-- User now has full system control
| Permission | Data-Reader | Data-Writer | Dbo | Admin |
|---|---|---|---|---|
| Data Access | ||||
| Read | ✅ | ✅ | ✅ | ✅ |
| Write | ❌ | ✅ | ❌ | ❌ |
| Update | ❌ | ✅ | ❌ | ❌ |
| Delete | ❌ | ✅ | ❌ | ❌ |
| Schema Management | ||||
| Create Bundle | ❌ | ❌ | ✅ | ❌ |
| Alter Bundle | ❌ | ❌ | ✅ | ❌ |
| Drop Bundle | ❌ | ❌ | ✅ | ❌ |
| Create Index | ❌ | ❌ | ✅ | ❌ |
| Database Management | ||||
| Create Database | ❌ | ❌ | ❌ | ✅ |
| Drop Database | ❌ | ❌ | ❌ | ✅ |
| Backup/Restore | ❌ | ❌ | ❌ | ✅ |
| User Management | ||||
| Create User | ❌ | ❌ | ❌ | ✅ |
| Grant Permission | ❌ | ❌ | ❌ | ✅ |
| Grant Role | ❌ | ❌ | ❌ | ✅ |
| System | ||||
| Migrations | ❌ | ❌ | ❌ | ✅ |
| System Config | ❌ | ❌ | ❌ | ✅ |
These are commonly used permission names in SyndrDB:
| Permission | Description | Common Users |
|---|---|---|
Read |
Read documents | All users (via Data-Reader) |
Write |
Write/Insert documents | Data-Writer role |
Update |
Update documents | Data-Writer role |
Delete |
Delete documents | Data-Writer role |
CreateBundle |
Create bundles | Dbo role |
AlterBundle |
Modify bundle schema | Dbo role |
DropBundle |
Delete bundles | Dbo role |
CreateIndex |
Create indexes | Dbo role |
Admin |
System administration | Admin role |
-- Developers get read-write access
CREATE USER "dev1" WITH PASSWORD 'DevPass!';
GRANT ROLE "Data-Writer" TO USER "dev1";
-- Database schema manager
CREATE USER "db_dev" WITH PASSWORD 'DbDevPass!';
GRANT ROLE "Dbo" TO USER "db_dev";
-- Application service (read-write only)
CREATE USER "app_prod" WITH PASSWORD 'ProdAppP@ss!';
GRANT ROLE "Data-Writer" TO USER "app_prod";
-- Read-only reporting
CREATE USER "reports_prod" WITH PASSWORD 'ReportsP@ss!';
-- Has Data-Reader by default, no additional grants
-- Production DBA (schema changes)
CREATE USER "dba_prod" WITH PASSWORD 'DbaProdP@ss!';
GRANT ROLE "Dbo" TO USER "dba_prod";
-- System administrator (full access)
CREATE USER "admin_prod" WITH PASSWORD 'AdminProdP@ss!';
GRANT ROLE "Admin" TO USER "admin_prod";
-- Test user with minimal access
CREATE USER "test_readonly" WITH PASSWORD 'TestP@ss!';
-- Only has Data-Reader
-- Test user with write access
CREATE USER "test_writer" WITH PASSWORD 'TestWriteP@ss!';
GRANT ROLE "Data-Writer" TO USER "test_writer";
-- Test admin (full access for testing)
CREATE USER "test_admin" WITH PASSWORD 'TestAdminP@ss!';
GRANT ROLE "Admin" TO USER "test_admin";
Modify an existing user's password. Other user attributes (IsActive, IsLockedOut) are currently managed by the system.
UPDATE USER "username" SET PASSWORD = "new_password";
UPDATE USER "username" SET PASSWORD = "new_password" FORCE;
| Parameter | Description | Required |
|---|---|---|
username |
The username to update | ✅ Required |
new_password |
The new password (8+ chars) | ✅ Required |
FORCE |
Terminate active sessions after update | ❌ Optional |
UPDATE USER "dev1" SET PASSWORD = "NewSecureP@ss123!";
UPDATE USER "app_user" SET PASSWORD = "NewP@ssword456!" FORCE;
The FORCE option will:
| Error | Cause | Solution |
|---|---|---|
| User not found | Username doesn't exist | Check username spelling |
| Weak password | Password < 8 characters | Use stronger password |
| Permission denied | Not an Admin | Log in as Admin |
| Invalid syntax | Missing SET PASSWORD | Follow syntax exactly |
FORCE when you suspect a password has been compromisedRemove permissions or roles from a user.
REVOKE "permission_name" FROM USER "username";
REVOKE "permission_name" FROM USER "username" FORCE;
REVOKE ROLE "role_name" FROM USER "username";
REVOKE ROLE "role_name" FROM USER "username" FORCE;
| Parameter | Description | Required |
|---|---|---|
permission_name |
Permission to revoke | ✅ Required (for permission) |
role_name |
Role to revoke | ✅ Required (for role) |
username |
Target user | ✅ Required |
FORCE |
Terminate active sessions | ❌ Optional |
REVOKE "Write" FROM USER "readonly_user";
REVOKE ROLE "Data-Writer" FROM USER "contractor1";
REVOKE "Admin" FROM USER "former_admin" FORCE;
REVOKE ROLE "Dbo" FROM USER "temp_dba" FORCE;
The FORCE option will:
| Error | Cause | Solution |
|---|---|---|
| User not found | Username doesn't exist | Check username spelling |
| Permission not granted | User doesn't have that permission | Check GRANT PERMISSION first |
| Role not granted | User doesn't have that role | Check GRANT ROLE first |
| Permission denied | Not an Admin | Log in as Admin |
FORCE when revoking critical permissions (Admin, Write, Delete)Remove a user from the system. This operation cascades to remove all associated permissions and role assignments.
DELETE USER "username";
DELETE USER "username" FORCE;
DROP USER "username";
DROP USER "username" FORCE;
Note: DELETE USER and DROP USER are aliases - they perform the same operation.
| Parameter | Description | Required |
|---|---|---|
username |
The username to delete | ✅ Required |
FORCE |
Terminate active sessions before deletion | ❌ Optional |
DELETE USER "contractor1";
DELETE USER "terminated_employee" FORCE;
DROP USER "old_account" FORCE;
Deleting a user automatically removes:
| Error | Cause | Solution |
|---|---|---|
| User not found | Username doesn't exist | Check username spelling |
| Cannot delete self | Trying to delete own account | Use different Admin account |
| Active sessions | User has active sessions | Use FORCE option |
| Permission denied | Not an Admin | Log in as Admin |
FORCE when deleting users to ensure clean removalThe following commands are not yet implemented in SyndrDB. They are planned for future releases.
-- PLANNED SYNTAX (not yet available):
CREATE ROLE "role_name" WITH PERMISSIONS ("Read", "Write");
UPDATE ROLE "role_name" ADD PERMISSION "Delete";
UPDATE ROLE "role_name" REMOVE PERMISSION "Write";
DROP ROLE "role_name";
Status: Roles are currently created during system initialization. There is no command to create, modify, or delete roles.
Workaround: Roles must be manually created by adding documents to the Roles bundle and RolesPermissions junction table.
The following features are planned for future implementation:
ROLE Management
Advanced Features
| Command | Syntax | Status |
|---|---|---|
| Create User | CREATE USER "name" WITH PASSWORD 'pass'; |
✅ Implemented |
| Update User | UPDATE USER "name" SET PASSWORD = "pass"; |
✅ Implemented |
| Delete User | DELETE USER "name"; or DROP USER "name"; |
✅ Implemented |
| Command | Syntax | Status |
|---|---|---|
| Grant Permission | GRANT "permission" TO USER "name"; |
✅ Implemented |
| Grant Role | GRANT ROLE "role" TO USER "name"; |
✅ Implemented |
| Revoke Permission | REVOKE "permission" FROM USER "name"; |
✅ Implemented |
| Revoke Role | REVOKE ROLE "role" FROM USER "name"; |
✅ Implemented |
| Command | Syntax | Status |
|---|---|---|
| Create Role | CREATE ROLE "name" ... |
❌ Not Implemented |
| Update Role | UPDATE ROLE "name" ... |
❌ Not Implemented |
| Delete Role | DROP ROLE "name"; |
❌ Not Implemented |
End of User & Security Commands Documentation