RBAC internals
Engineering view of the role + admin sync system. For the operational view see Platform Admin → Roles & permissions.
Source of truth
apps/sellub/sellub-server/admin-config/admins.json
{
"roles": [
{
"code": "platform-support",
"description": "Tier 1 support — read-mostly",
"permissions": ["ReadOrder", "ReadCustomer", "ReadAdministrator"],
"channels": ["*"]
}
],
"admins": [
{
"emailAddress": "alice@sellub.com",
"firstName": "Alice",
"lastName": "Mensah",
"roleCodes": ["platform-support"],
"disabled": false
}
],
"_unmanaged_accounts": [
"legacy@partner.com"
]
}The sync script
apps/sellub/sellub-server/scripts/sync-admins.ts
Idempotent. Steps:
- Load
admins.jsonfor the target env. - Validate every
roleCodes[]references a role inroles[]. - Validate every permission name exists in Vendure’s
Permissionenum. - For each role:
- Upsert the
Rolerecord bycode. - Replace the role’s
permissionsandchannelsto match JSON.
- Upsert the
- For each admin in
admins[]:- Find or create the
AdministratorbyemailAddress. - If creating, generate a temp password and print it once.
- Replace the admin’s role assignments to match
roleCodes. - Set
disabledflag.
- Find or create the
- For every existing
Administratornot inadmins[]and not in_unmanaged_accounts:- Set
disabled = true(do not delete — preserves audit trail).
- Set
- Print a diff summary: created / updated / disabled.
SuperAdmin recovery
Script: apps/sellub/sellub-server/scripts/recover-superadmin.ts.
Requires shell access to the prod server.
docker compose exec sellub-server node dist/scripts/recover-superadmin.jsWhat it does:
- Finds the SuperAdmin with the lowest ID (the bootstrap account).
- Generates a 15-minute one-time password.
- Stores its hash + expiry on the account.
- Prints the password to stdout.
- Logs the recovery to the audit log table.
The recovered admin must change password on first sign-in.
Permission enum reference
Vendure’s full Permission enum: https://docs.vendure.io/reference/typescript-api/common/permission/.
Custom permissions added by Sellub plugins:
| Permission | Granted by | What it gates |
|---|---|---|
ApproveSellerApplication | Onboarding+ | Seller approval workflow |
AdjustSellerWallet | SuperAdmin, Finance | Wallet adjustments |
ManageDomainVerification | Platform Admin | Custom-domain DNS / cert |
IssueApiKey | SuperAdmin, Integrations | API key issuance |
These are registered in sellub-server/src/plugins/<plugin>/permissions.ts.
CI validation
.github/workflows/validate-admins.yml runs on every PR touching admins.json:
- JSON schema check.
pnpm sync-admins --dry-runagainst an in-memory DB.- Diff comment on the PR showing what would change in production.