What Problems Do Sub-accounts Solve?
1. Organizational Structure Management
- ✅ Create isolated account spaces for different departments or business units
- ✅ Maintain separate administrative control for each sub-account
- ✅ Enable independent data management per sub-account
- ✅ Support hierarchical organizational structures
2. Multi-tenant SaaS Applications
- ✅ Provide isolated data storage for each customer
- ✅ Enable customer-specific administrative access
- ✅ Maintain complete data separation between accounts
- ✅ Support white-label or reseller scenarios
3. Compliance and Data Isolation
- ✅ Ensure complete data isolation between sub-accounts
- ✅ Meet regulatory requirements for data separation
- ✅ Enable independent audit trails per sub-account
- ✅ Support compliance with data residency requirements
Implementation Approaches
Databunker Pro provides two primary approaches for implementing sub-accounts:- Multi-tenancy Support - Creates isolated tenants with dedicated admin tokens
- Groups with Roles and Policies - Uses Databunker Pro’s CRBAC system for group-based management
Approach 1: Multi-tenancy Support
Multi-tenancy is the recommended approach when you need complete data isolation and independent administrative control for each sub-account. After creating a tenant, you receive a tenant admin token that allows full management of all records within that tenant.How It Works
When you create a new tenant using the multi-tenancy feature:- A new isolated tenant is created with its own data namespace
- A tenant admin token is generated that provides full administrative access
- All records created within this tenant are completely isolated from other tenants at the database level using PostgreSQL’s row-level security (RLS). Note: Multi-tenancy requires PostgreSQL and is not supported with MySQL.
- The tenant admin token can manage all user records, application data, and configurations within the tenant
Creating a Sub-account with Multi-tenancy
Using the Tenant Admin Token
Once you have the tenant admin token, you can use it to manage all records within that tenant:JavaScript/TypeScript Example
Python Example
Benefits of Multi-tenancy Approach
- Complete Data Isolation: Each tenant has its own isolated data namespace
- Independent Administration: Tenant admin tokens provide full control within the tenant
- Scalability: Supports unlimited tenants with PostgreSQL row-level security (requires PostgreSQL, not available with MySQL)
- Security: Built-in tenant separation at the database level
- Compliance: Meets data residency and isolation requirements
Approach 2: Groups with Roles and Policies
The groups approach leverages Databunker Pro’s Conditional Role-Based Access Control (CRBAC) system. Each group can store sub-accounts, and a group admin user manages all users within that group. This approach is implemented using roles and policies.How It Works
With the groups approach:- Create a group to represent the sub-account
- Assign a group admin role to a user who will manage the sub-account
- Create policies that grant the group admin access to manage users within the group
- Add users to the group as needed
- The group admin can manage all users within their assigned group
Creating a Sub-account with Groups
Creating Policies for Group Admin
Create a policy that allows the group admin to manage all users within their group:JavaScript/TypeScript Example
Benefits of Groups Approach
- Flexible Access Control: Fine-grained permissions using CRBAC policies
- Role-Based Management: Different roles can be assigned within groups
- Conditional Access: Policies can include complex conditions for access control
- Compliance Support: Supports FERPA, GDPR, and DPDPA compliance scenarios
- Hierarchical Structures: Supports parent-child relationships within groups
Choosing the Right Approach
Use Multi-tenancy When:
- You need complete data isolation between sub-accounts
- Each sub-account requires independent administrative control
- You’re building a multi-tenant SaaS application
- You need to meet strict data residency requirements
- You want database-level isolation for security (requires PostgreSQL, not available with MySQL)
Use Groups Approach When:
- You need flexible, role-based access control within sub-accounts
- You want to implement hierarchical organizational structures
- You need conditional access policies (e.g., parent-child relationships)
- You’re building compliance-focused applications (FERPA, GDPR, DPDPA)
- You want fine-grained permissions for different user roles
Real-World Use Cases
1. SaaS Multi-tenant Application
Create isolated sub-accounts for each customer:2. Departmental Sub-accounts
Organize departments within an organization:3. Reseller/Partner Program
Enable partners to manage their own customer data:Security Considerations
Multi-tenancy Security
- Row-Level Security: PostgreSQL RLS ensures tenant data isolation (requires PostgreSQL, not available with MySQL)
- Token-Based Access: Tenant admin tokens are scoped to their tenant
- Audit Logging: All tenant operations are logged separately
- Encryption: Each tenant’s data is encrypted independently
Groups Security
- Policy Enforcement: CRBAC policies control all access
- Role Validation: Roles are verified before granting access
- Condition Checks: Policies include conditions for additional security
- Audit Trail: All group operations are logged with role information
Best Practices
- Token Management: Securely store and rotate tenant admin tokens
- Policy Design: Design policies carefully to ensure proper access control
- Regular Audits: Review sub-account access and permissions regularly
- Monitoring: Monitor sub-account activity for security and compliance
- Documentation: Document which approach is used for each sub-account
Conclusion
Databunker Pro provides two powerful approaches for implementing sub-accounts:- Multi-tenancy offers complete isolation and independent administration
- Groups with CRBAC provides flexible, role-based access control
- Use multi-tenancy for complete isolation and independent administration
- Use groups for flexible role-based access control and hierarchical structures
- Combine both approaches for maximum flexibility with database-level isolation and fine-grained permissions