How RBAC Works in mgPass
mgPass uses a three-layer RBAC model. Understanding these layers is essential for securing your applications:Layer 1: API Resources & Scopes
An API Resource represents a protected API. Scopes define what capabilities that API exposes. Think of it like this:- API Resource = “adesa+ Streaming API” (the thing being protected)
- Scopes = “stream:live”, “stream:vod”, “content:download” (the permissions within it)
Layer 2: Roles
A Role is a named collection of scopes drawn from one or more API resources. Roles are what you assign to users — not individual scopes.| Role | Scopes | Who gets it |
|---|---|---|
| mgpass:user | profile:read | Everyone (default role) |
| adesa:subscriber | stream:live, stream:vod, profile:read | Paid adesa+ users |
| adesa:premium | stream:live, stream:vod, content:download, profile:read | Premium subscribers |
| mgtix:organizer | events:create, events:read, tickets:manage | Event organizers |
| mgpass:admin | Full admin access | MG Digital staff |
Layer 3: Role Assignment
Roles are assigned to users. A user can have multiple roles. Assignment happens through:- Manual — an admin assigns via the console or API
- Automatic — roles marked
is_defaultare assigned on registration - Programmatic — your backend calls the mgPass API when a subscription is purchased
Setting Up RBAC (Admin Console)
Step 1: Create an API Resource
Navigate to Roles > API Resources
In the admin console, go to Roles in the sidebar, then click the API Resources tab at the top.
Create the resource
Fill in:
- Name — human-readable label (e.g., “adesa+ Streaming API”)
- Identifier — unique URI used as the
audiencein JWTs (e.g.,https://api.adesa.com.gh)
Step 2: Create Roles
Create a new role
Click Create Role. Fill in:
- Name — unique identifier (e.g.,
adesa:subscriber) - Description — what this role represents
- Type —
userfor human users,m2mfor machine-to-machine apps
Assign scopes to the role
On the role detail page, use the scope assignment section to add scopes from your API resources. Check the scopes this role should include.
Step 3: Assign Roles to Users
Setting Up RBAC (API)
Create an API Resource
Add Scopes
Create a Role
Assign Scopes to a Role
Assign a Role to a User
Remove a Role
How Scopes Appear in JWTs
When a user authenticates, mgPass builds their access token by:- Collecting all roles assigned to the user
- Gathering all scopes from those roles
- Filtering to only scopes the application is allowed to request
- Including the final scope list in the JWT
scope claim:
Default Roles
Roles withis_default: true are automatically assigned to every new user on registration. Use this for:
mgpass:user— basic profile access everyone needs- A “free tier” role with limited permissions
Default roles only apply to new registrations. Existing users without the role are not affected. To backfill, assign the role via the API or admin console.
M2M Roles
Machine-to-machine applications (backend services) get roles too, but their roles havetype: "m2m". These roles:
- Can only be assigned to M2M applications, not to users
- Define what APIs the service can call
- Scopes appear in the access token from the Client Credentials grant
- Create an M2M role
rewards:servicewith scopeusers:read - Assign it to the mgRewards M2M application
- mgRewards authenticates with Client Credentials and gets a token with
users:read
Real-World Example: adesa+ Integration
Here’s how the full RBAC setup works for adesa+:Create API Resource
Name: “adesa+ API”, Identifier:
https://api.adesa.com.gh
Scopes: stream:live, stream:vod, content:download, profile:readCreate Roles
- adesa:free —
stream:live(limited),profile:read - adesa:subscriber —
stream:live,stream:vod,profile:read - adesa:premium — all scopes including
content:download
Register adesa+ as an Application
Type: Native (mobile) / SPA (web). Allowed scopes: all adesa+ scopes.
Assign Roles on Subscription
When a user purchases a subscription through your billing system, call the mgPass API:
Best Practices
Principle of Least Privilege
Give roles only the scopes they need. A subscriber doesn’t need
content:download — that’s for premium.Use Meaningful Names
adesa:subscriber is better than role_1. Names appear in admin UI and audit logs.One Default Role
Keep one default role for baseline access. Don’t auto-assign premium permissions.
Scope at the API Level
Check scopes in your API, not in the frontend. The frontend can hide UI elements, but the API enforces access.

