Access Control & Permissions

Module Code: PERM Priority: P0 (Critical Foundation - Required for authorization) Status: New (To be developed) Dependencies: User Access & Security



Module Overview

Purpose: Comprehensive role-based access control (RBAC) system defining who can do what in the dealership management system.

Priority: P0 (Critical Foundation - Required for authorization)

Dependencies: User Access & Security (M00)

Integration Points: All modules (every module enforces permissions)


Functional Specifications

1.1 Role Management

Role Definition:

AttributeDescriptionExample
Role IDUnique identifierUUID
Role NameHuman-readable nameSales Manager
Role CodeSystem codeSALES_MGR
DescriptionPurpose of roleManages sales team and approves deals
DepartmentAssociated departmentSales
LevelHierarchy levelManager (2)
Is System RoleProtected from deletionYes (for Admin)
Active StatusEnable/disable roleActive

System Roles (Pre-defined, cannot be deleted):

RoleCodeLevelDescription
System AdministratorSYS_ADMIN0Full system access, all permissions
IT AdministratorIT_ADMIN1Technical administration, no business data
General ManagerGM2Full business operations access
Sales ManagerSALES_MGR3Sales department management
Service ManagerSVC_MGR3Service department management
Parts ManagerPARTS_MGR3Parts department management
Sales AdvisorSALES_ADV4Sales consultant, limited permissions
Service AdvisorSVC_ADV4Service consultant
TechnicianTECH4Workshop technician
Parts SpecialistPARTS_SPEC4Parts counter staff
Cashier/AccountantCASHIER4Financial transactions
Customer ServiceCS_REP4Customer care representative
ReceptionistRECEPT5Front desk, basic access
Read-Only AuditorAUDITOR5View-only access for compliance

Custom Role Creation:

StepActionValidation
1Define role name and codeUnique code required
2Assign departmentOptional
3Set hierarchy level1-10
4Add descriptionRequired
5Copy permissions from templateOptional starting point
6Customize permissionsModule by module
7Set data scope rulesOwn/Department/All
8Review and saveAdmin approval

Role Operations:

OperationDescriptionWho Can Do
Create RoleCreate new custom roleSystem Admin only
Edit RoleModify role details and permissionsSystem Admin only
Clone RoleDuplicate existing role as templateSystem Admin only
Activate/DeactivateEnable or disable roleSystem Admin only
Delete RoleRemove custom roleSystem Admin (if not in use)
Assign to UserGive role to userSystem Admin, Managers
View Role DetailsSee role configurationAdmin, IT Admin

1.2 Permission Structure

Permission Hierarchy:

Module Level
    β”œβ”€β”€ Feature/Section Level
    β”‚       β”œβ”€β”€ Action Level (CRUD)
    β”‚       β”‚       β”œβ”€β”€ Create
    β”‚       β”‚       β”œβ”€β”€ Read/View
    β”‚       β”‚       β”œβ”€β”€ Update/Edit
    β”‚       β”‚       └── Delete
    β”‚       └── Special Actions
    β”‚               β”œβ”€β”€ Approve
    β”‚               β”œβ”€β”€ Export
    β”‚               └── Print
    └── Data Scope
            β”œβ”€β”€ Own Records Only
            β”œβ”€β”€ Department Records
            └── All Records

Permission Types:

TypeLevelExample
Module AccessModuleCan access Sales module
Feature AccessSectionCan access Quotations section
CRUD PermissionsActionCan create quotations
Special PermissionsActionCan approve discounts
Data ScopeFilterCan view all quotations vs own only
Field-LevelGranularCan view price but not edit

Standard Permission Actions:

ActionCodeDescription
View/ReadVIEWCan see records
CreateCREATECan create new records
Edit/UpdateUPDATECan modify existing records
DeleteDELETECan remove records
ApproveAPPROVECan approve pending items
RejectREJECTCan reject submissions
ExportEXPORTCan export data to files
PrintPRINTCan print documents
ImportIMPORTCan bulk import data
AssignASSIGNCan assign to other users

1.3 Permission Assignment

Permission Matrix by Module:

Example for M10: Sales Operations

PermissionSales AdvisorSales ManagerGeneral Manager
View QuotationsOwn onlyAllAll
Create QuotationsYesYesYes
Edit QuotationsOwn onlyAllAll
Delete QuotationsNoOwn deptAll
Approve Discounts 0-5%YesYesYes
Approve Discounts 5-10%NoYesYes
Approve Discounts >10%NoNoYes
View Cost PricesNoYesYes
View All CustomersDepartmentAllAll
Reassign LeadsOwn onlyDepartmentAll
Export Sales ReportNoYesYes

Data Scope Rules:

ScopeDescriptionExample
OwnOnly records created by or assigned to userSales advisor sees only their own customers
TeamRecords from user’s teamTeam lead sees team members’ data
DepartmentAll records in user’s departmentSales manager sees all sales dept data
LocationRecords from user’s branchManager sees only their branch
AllAll records in systemGM sees all locations, all departments
Custom FilterSpecific criteria-based filterOnly customers in VIP segment

Permission Inheritance:

RuleDescription
Multiple RolesUser inherits permissions from ALL assigned roles (union)
Higher Permission WinsIf one role allows and another denies, allow wins
Data Scope WidestWidest data scope applies (All > Dept > Own)
Explicit DenyExplicit deny overrides implicit allow

1.4 Role Assignment to Users

User-Role Relationship:

AttributeDescription
User IDUser account
Role IDAssigned role
Assigned ByWho assigned the role
Assigned AtWhen role was assigned
Effective FromWhen role becomes active
Effective UntilRole expiration (optional)
Is Primary RoleUser’s main role (for display)
Assignment ReasonNotes on why role assigned

Assignment Process:

StepAction
1Admin/Manager selects user
2Choose role(s) to assign
3Set effective date range (optional)
4Mark primary role
5Add assignment notes
6Save and notify user
7User logs out and back in to activate

Assignment Rules:

RuleDescription
Minimum One RoleEvery user must have at least one active role
Primary Role RequiredOne role must be marked as primary
No Conflicting RolesCannot assign conflicting dept roles (Sales + Service Manager)
Manager ApprovalRole assignments may require manager approval
Expiry WarningAlert 7 days before role expires
Auto-DeactivateDeactivate user if all roles expired

1.5 Approval Workflows

Approval Limits by Role:

Example for Discount Approvals:

RoleMax DiscountMax Deal ValueRequires Higher Approval
Sales Advisor3%$50,000Above limits
Sales Manager10%$200,000Above limits
General Manager15%$500,000Above limits
Owner/CEOUnlimitedUnlimitedNone

Approval Matrix Example:

ActionRequires Approval FromConditions
Create QuotationNone-
Apply 5% DiscountSales ManagerIf advisor discount >3%
Apply 10% DiscountGeneral ManagerIf any discount >10%
Write-off Bad DebtCFO + GMAmount >$10,000
Delete Sales OrderSales ManagerAfter deposit received
Refund CustomerAccountant + ManagerAny refund

Approval Workflow:

StepAction
1User submits request (e.g., high discount)
2System checks approval requirements
3Notification sent to approver
4Approver reviews request with context
5Approver approves or rejects with comments
6Requester notified of decision
7If approved, action proceeds
8All steps logged in audit trail

1.6 Permission Checking Engine

Runtime Permission Check:

StepCheckResult
1Is user authenticated?Proceed if yes
2Is session valid?Proceed if yes
3Get user’s rolesLoad from cache/DB
4Get permissions for rolesUnion of all role permissions
5Check module accessDoes user have module permission?
6Check action permissionDoes user have action permission?
7Apply data scope filterFilter data based on scope
8Grant or deny accessReturn boolean + filtered data

Permission Caching:

Cache TypeDurationInvalidation
User PermissionsSession lifetimeRole change, logout
Role Definition1 hourRole updated
Module Permissions30 minutesPermission change

Performance Optimization:

OptimizationDescription
Permission Pre-loadingLoad all user permissions on login
Cache in SessionStore in session, not DB lookup per request
Lazy LoadingLoad module permissions only when accessed
Batch ChecksCheck multiple permissions in one call

1.7 Delegation & Temporary Access

Delegation:

FeatureDescription
Delegate AuthorityUser can delegate their permissions to another user temporarily
Delegation PeriodStart and end date/time
Partial DelegationDelegate specific permissions only, not all
Revoke EarlyOriginal user can revoke before end date
Audit TrailAll delegated actions logged with both users

Delegation Process:

StepAction
1User initiates delegation
2Select delegate (another user)
3Choose permissions to delegate
4Set time period
5Add justification
6Manager approval (if required)
7Delegate notified
8Delegated permissions active

Temporary Access:

Use CaseDurationApproval
Vacation Coverage1-4 weeksManager approval
Project CollaborationProject durationDepartment head approval
Emergency Access24 hoursPost-approval review
Training/ShadowingVariableManager approval

1.8 Reporting & Analytics

Role Reports:

ReportDescription
Role MembershipAll users assigned to each role
Permission MatrixComplete permission grid by role
Orphaned UsersUsers with no active roles
Over-Privileged UsersUsers with excessive permissions
Role UsageHow often each role is used
Permission ConflictsConflicting permission assignments

Audit Reports:

ReportDescription
Role ChangesAll role modifications over time
Assignment HistoryWho assigned what role to whom
Access Denied LogPermission denials and reasons
Delegation LogAll delegation activities
Approval HistoryApproval requests and outcomes

Compliance Reports:

ReportPurpose
Segregation of DutiesEnsure no user has conflicting roles
Access CertificationPeriodic review of user access
Privilege EscalationTrack permission increases
Unused PermissionsPermissions never used (candidates for removal)

Data Model

Role Table:

FieldTypeDescription
role_idUUIDPrimary key
role_nameVARCHAR(100)Display name
role_codeVARCHAR(50)System code (unique)
descriptionTEXTPurpose and scope
departmentVARCHAR(50)Associated department
hierarchy_levelINTOrganizational level (0-10)
is_system_roleBOOLEANProtected system role
is_activeBOOLEANRole enabled/disabled
created_byUUIDCreator user ID
created_atTIMESTAMPCreation time
updated_atTIMESTAMPLast update

Permission Table:

FieldTypeDescription
permission_idUUIDPrimary key
module_codeVARCHAR(50)Module identifier (M01, M02, etc.)
feature_codeVARCHAR(50)Feature/section within module
action_codeVARCHAR(50)Action (VIEW, CREATE, UPDATE, etc.)
permission_nameVARCHAR(200)Human-readable name
permission_codeVARCHAR(100)Unique code
is_dangerousBOOLEANHigh-risk permission flag
created_atTIMESTAMPCreation time

Role-Permission Table:

FieldTypeDescription
role_permission_idUUIDPrimary key
role_idUUIDForeign key to role
permission_idUUIDForeign key to permission
data_scopeENUMOwn/Team/Dept/Location/All
granted_byUUIDWho granted permission
granted_atTIMESTAMPWhen granted

User-Role Table:

FieldTypeDescription
user_role_idUUIDPrimary key
user_idUUIDForeign key to user
role_idUUIDForeign key to role
is_primaryBOOLEANPrimary role flag
assigned_byUUIDWho assigned
assigned_atTIMESTAMPAssignment time
effective_fromTIMESTAMPStart date
effective_untilTIMESTAMPEnd date (optional)
assignment_reasonTEXTNotes
is_activeBOOLEANCurrently active

Approval Limits Table:

FieldTypeDescription
limit_idUUIDPrimary key
role_idUUIDForeign key to role
approval_typeVARCHAR(50)Discount, Refund, Write-off, etc.
max_amountDECIMALMaximum monetary value
max_percentageDECIMALMaximum percentage
requires_approval_fromUUID[]Required approver roles
effective_fromTIMESTAMPStart date
effective_untilTIMESTAMPEnd date

Delegation Table:

FieldTypeDescription
delegation_idUUIDPrimary key
delegator_user_idUUIDUser delegating
delegate_user_idUUIDUser receiving delegation
permission_idsUUID[]Delegated permissions
start_timeTIMESTAMPDelegation start
end_timeTIMESTAMPDelegation end
reasonTEXTJustification
approved_byUUIDApprover
is_activeBOOLEANCurrently active
revoked_atTIMESTAMPEarly revocation

Business Rules

Role Management Rules:

RuleDescription
System Roles ProtectedCannot delete or modify critical system roles
Unique Role CodesRole codes must be unique system-wide
Active Role DeletionCannot delete role if assigned to active users
Hierarchy RespectLower-level roles cannot have permissions higher-level roles lack

Permission Rules:

RuleDescription
No Orphan PermissionsEvery permission must belong to at least one role
Permission ConsistencyCreate permission should not exist without View
Dangerous Permission LoggingHigh-risk permissions trigger extra audit logging
Default DenyEverything denied unless explicitly granted

Assignment Rules:

RuleDescription
Minimum One RoleUsers must have at least one active role
Department ConsistencySales Manager role only for Sales dept employees
Conflict DetectionSystem warns on conflicting role assignments
Expiry NotificationAlert users 7 days before role expiration

Approval Rules:

RuleDescription
Self-Approval ForbiddenUsers cannot approve their own requests
Chain of ApprovalHigher authority can override lower approvals
Approval TimeoutRequests pending >7 days escalate to higher level
Emergency OverrideGM can override approval process (logged)

Integration Points

Outbound Integrations:

ModuleIntegration Purpose
User Access & SecurityProvide permission set for authorization
Employee DirectoryLink roles to departments and positions
All Business ModulesEnforce permissions on all operations
M27 Business IntelligencePermission-based report access

Inbound Integrations:

ModuleIntegration Purpose
User Access & SecurityReceive authentication events
Employee DirectoryAuto-assign roles based on job position
Company ConfigurationDepartment-based role filtering

User Roles & Permissions

Who Can Manage Roles:

RoleView RolesCreate RolesEdit RolesDelete RolesAssign Roles
System AdminAllYesAllCustom onlyAll users
IT AdminAllNoNoNoNo
General ManagerAllNoNoNoDepartment users
Department ManagerDepartmentNoNoNoDepartment users

Key Performance Indicators

Role Management Metrics:

MetricTargetMeasurement
Roles per User1-3 averageAvg roles assigned per user
Orphaned Users0Users with no active roles
Unused Roles< 5%Roles with 0 users
Permission Conflicts0Conflicting permission assignments
Access Denials< 1% of requestsDenied / Total permission checks

Compliance Metrics:

MetricTargetMeasurement
Access Reviews100% annually% users reviewed per year
Segregation of Duties0 violationsConflicting role combinations
Over-privileged Users< 5%Users with excessive permissions
Delegation Compliance100% approved% delegations with approval

Last Updated: November 14, 2025 Version: 6.0 Migrated From: P0_Baseline_Modules.md