masaruk Logo

Roles & Permissions

Roles & Permissions Matrix (RBAC) for all MASARUK systems

1. Purpose of This Document

This document defines the complete Roles & Permissions model (RBAC) across all MASARUK systems:

  • Admin Panel (Super Admin + Admin)
  • Provider Portal (Provider Admin + Provider Staff)
  • B2C Web
  • Mobile App

The matrix ensures consistent authorization across: Node.js Backend (RBAC middleware), Next.js Web (React Query access rules), Flutter Mobile App (feature gating), Admin / Provider dashboards.

2. Role Definitions

SUPER_ADMIN

The highest privileged role. Full access to all modules, settings, financials, providers, users, and platform-wide configuration.

ADMIN

Internal platform admin (but not owner). Manages trips, bookings, financial reports, user support, and approvals — but cannot modify system-wide settings.

PROVIDER_ADMIN

Owner/manager of a tourism company. Can create and manage: Trips, Hotels, Buses, Drivers, Rest stops, Ad campaigns. View bookings related to their own trips only.

PROVIDER_STAFF

Limited access within a provider company. View & edit trips, manage buses/hotels/rest stops (except deletion). Cannot access financial reports or ad campaign billing.

CUSTOMER (END_USER)

B2C user on Web & Mobile. Browse trips, create bookings, pay online, rate completed trips, manage own profile & bookings only.

FINANCE_ADMIN

Responsible for: Financial records, payout statuses, exporting reports.

SUPPORT_AGENT

Customer support role (view-only access to bookings + send messages).

3. Global Permission Categories

CategoryModules Included
Users ManagementUsers, Providers, Provider Staff
Trips ManagementTrips, Hotels, Buses, Drivers, Rest Stops
Booking OperationsBookings, Passengers, Cancellations, Messaging
Ratings & ReviewsTrip ratings from mobile flow
Ad CampaignsPaid campaigns & payment steps
Financial ReportsSales, commissions, payouts
Platform SettingsSystem config, SMS/email settings
AuthenticationLogin, Signup, JWT Tokens

4. Permissions Legend

VView
CCreate
UUpdate
DDelete
AAdministrative actions
XExecute business action

5. Full RBAC Matrix

5.1 User & Provider Management

ActionSUPER_ADMINADMINPROVIDER_ADMINPROVIDER_STAFFCUSTOMER
View platform usersV C U DV---
Manage providersV C U D AV U---
Manage provider staffV C U DV UV C U D*--
Edit own profile--UUU

* only own provider

5.2 Trips Management

ActionSUPER_ADMINADMINPROVIDER_ADMINPROVIDER_STAFFCUSTOMER
View all tripsVVV*V*V
Create new tripCCCC-
Update tripUUUU-
Delete tripDDD--
Manage hotelsV C U DV C U DV C U D*V C U-
Manage busesV C U DV C U DV C U D*V C U-

* only own provider's resources

5.3 Bookings & Passengers

ActionSUPER_ADMINADMINPROVIDER_ADMINSUPPORTCUSTOMER
View all bookingsVVV*VV**
Create bookingXX--C
Cancel bookingXXX*-X***
Send message to customerXX-X-

* own trips only | ** own bookings only | *** subject to cancellation policy

5.4 Payments & Financial Records

ActionSUPER_ADMINADMINPROVIDER_ADMINFINANCECUSTOMER
View payment transactionsVVV*VV*
Issue refundsXX-X-
View financial reportsVVV*V-
Export reportsXXX*X-
Update payout statusXX-X-

* own records only

5.5 Ad Campaigns

ActionSUPER_ADMINADMINPROVIDER_ADMINPROVIDER_STAFFCUSTOMER
View campaignsVVV*V*-
Create campaignCCC--
Edit campaignUUU--
Pay for campaignXXX--

* own campaigns only

5.7 Scheduled Dates Management (Slice 9)

SSOT: trips-module.md §12

ActionSUPER_ADMINADMINPROVIDER_ADMINPROVIDER_STAFF
View scheduled datesVVV*V*
Create single dateCCCC
Bulk generate datesCCC
Edit scheduled dateUUU*U*
Delete scheduled dateDDD*
Change to INACTIVEAAA*
Change to SOLD_OUTAAA*A*
Change to CANCELLEDAAA*

PROVIDER_STAFF cannot bulk generate, delete, or cancel. Dates with bookings cannot be deleted/edited (departure_datetime).

6. Cross-Module Permission Notes

6.1 Provider Isolation

Provider Admin / Staff cannot see or manage trips, bookings, or financials belonging to another provider.

This is enforced at the API level via:

  • provider_id matching
  • scopes in token
  • Policy conditions

6.2 Customer Data Protection

Customers cannot:

  • Access admin APIs
  • View other users' data
  • Modify trip or financial data

7. Technical Implementation

// Node.js RBAC Middleware Example
const requireRoles = (...allowedRoles: UserRole[]) => {
  return (req, res, next) => {
    if (!req.user || !allowedRoles.includes(req.user.role)) {
      return res.status(403).json({ error: 'FORBIDDEN' });
    }
    next();
  };
};

// Usage Example
router.post('/trips', authMiddleware, requireRoles(UserRole.PROVIDER_ADMIN), tripsController.create);

// Provider Scope Middleware
const providerScopeMiddleware = (req, res, next) => {
  if (req.user.role === 'PROVIDER_ADMIN' || req.user.role === 'PROVIDER_STAFF') {
    req.providerScope = req.user.providerId;
  }
  next();
};