mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
4.4 KiB
4.4 KiB
IAM Org Structure
Core Model
Organization
- Top-level tenant or company.
- Entity:
Organization - Has:
units,positions,employees - Supports hierarchy through
parentandbranches
Unit
- Organizational subdivision under an organization.
- Entity:
Unit - Belongs to
organizationId - Supports hierarchy through
parentUnitandsubUnits - Has:
positions,positionTypes,employees,employeePositions
Department
- In the IAM UI, a department is effectively a
Position. - There is no separate backend
Departmententity in this package. - In the org tree UI:
- Organization -> Unit -> Department ~= Position
- Sub-department ~= subPosition
Position
- The actual backend model behind the UI's department concept.
- Entity:
Position - Belongs to:
unitId,organizationId - Supports hierarchy through
parentPositionIdandsubPositions - Has assigned people through
employeePositions - Can have direct permissions through
positionPermission - Also linked to a
positionType
Position Type
- Template or category for positions.
- Entity:
PositionType - Example seeded concepts include things like employee, team leader, director, deputy.
- Can carry permissions through
position_type_permissions
Employee
- Org-scoped representation of a person inside an organization and unit.
- Entity:
Employee - Links a
UserintoorganizationIdandunitId - Has
employeePositions[]for actual assignments - Uses
isCurrentandstatusto indicate active records
EmployeePosition
- Assignment join between
EmployeeandPosition. - Entity:
EmployeePosition - Holds the active working context:
isCurrentstatusisDelegatedelegatorIdstartDateandendDate
- This is the position context the auth layer ultimately uses
User
- Global identity record.
- Entity:
User - Has login/account fields like
username,email,phoneNumber - Has:
userRoles[]employee[]
- A single user can have multiple employee records and multiple org assignments
Role
- RBAC grouping of permissions.
- Entity:
Role - Assigned to users via
UserRole - Has permissions via
RolePermission
Permission
- Atomic authorization capability.
- Entity:
Permission - Main fields include
key,name, and optionalapplicationKey - Can be granted through:
role_permissionsposition_permissionsposition_type_permissions
Relationship Summary
Organizationcontains manyUnitrecords.Unitcontains manyPositionrecords.- The UI calls those positions departments.
Useris the identity.Employeelinks that user to an organization and unit.EmployeePositionlinks the employee to one or more positions.Roleis assigned directly to the user viaUserRole.Permissioncan come from the user's roles, the position itself, or the position type.
Runtime Permission Model
At login, IAM builds a session userInfo payload that includes:
roles: fromuserRolespermissions: flattened from role permissionsemployee.positions[].permissions: combined from:- direct
positionPermission - inherited
positionTypePermissions
- direct
This means authorization has two practical layers:
- User-level permissions from roles
- Position-context permissions from the active position and its type
Active Context During Requests
The auth guard uses request headers to decide which employee position is the current working context.
Important headers include:
x-current-position-idx-delegator-position-idx-current-project-idx-organization-unit-id
That selected context becomes the active request.user.employee.position and is also used for auditing.
Practical Mental Model
Use this simplified model when reasoning about IAM:
- A
Useris the account. - An
Employeeis that user inside an organization. - A
Positionis the department-like slot in the org tree. - An
EmployeePositionsays which employee occupies which position. - A
Rolegives broad user-level permissions. - A
PositionandPositionTypegive contextual working permissions.
UI Mapping
In @tria-plc/iamui-common user management:
- Organizations ->
Organization - Units ->
Unit - Departments ->
Position - Sub-departments -> child
Position - Team members/employees ->
EmployeeplusEmployeePosition - Roles ->
Role - Permissions ->
Permission