Skip to content

Commit d824505

Browse files
committed
docs: align all functional specifications with identity abstraction (ADR-0031)
1 parent 401a2e8 commit d824505

14 files changed

Lines changed: 47 additions & 47 deletions

src/ums-workspace/docs/en/01-requirements/conceptual-data-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ erDiagram
5050
- `organization_id` (UUID, FK): Owning tenant organization.
5151
- `email` (string, Unique): Corporate email address.
5252
- `password_hash` (string, **Nullable**): Populated **only** when the Internal Bcrypt Strategy adapter is active for the organization. `NULL` when authentication is delegated to an external IdP.
53-
- `employee_reference` (string): External unique ID linking to corporate HR/ERP records.
53+
- `identity_reference` (string): External unique ID linking to corporate HR/ERP records.
5454
- `status` (enum): `ACTIVE`, `SUSPENDED`, or `TERMINATED`.
5555
- `created_at` (timestamp): Record creation timestamp.
5656

src/ums-workspace/docs/en/01-requirements/functional-stories/fs-01-user-authentication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ sequenceDiagram
3939
2. The web client redirects the user to the configured external Identity Provider (Keycloak/Azure AD) authorization endpoint using **OAuth 2.0 Auth Code Flow with PKCE**.
4040
3. The user authenticates successfully using their corporate credentials on the IdP portal.
4141
4. The IdP redirects the browser back to the SCM portal with an authorized single-use Authorization Code.
42-
5. The SCM backend exchanges the Authorization Code with the IdP for a cryptographically signed Access Token (JWT) containing employee claims.
43-
6. The backend verifies the token's RS256 signature and validates that the `employee_reference` matches an active employee record in the local SCM database.
42+
5. The SCM backend exchanges the Authorization Code with the IdP for a cryptographically signed Access Token (JWT) containing identity claims.
43+
6. The backend verifies the token's RS256 signature and validates that the `identity_reference` matches an active identity record in the local SCM database.
4444
7. The system initializes the user session, injects the tenant context, and returns a secure, HTTP-Only, SameSite=Strict session cookie.
4545

4646
---
@@ -51,8 +51,8 @@ sequenceDiagram
5151
* If the connection to Keycloak/Azure AD fails, the SCM Gateway intercepts the timeout error.
5252
* The system displays a secure fallback credentials page allowing authorized IT Administrators to login using local ULPMS emergency credentials, while standard operators are prompted to retry.
5353

54-
### Alternative Flow B: Unlinked Employee Reference
55-
* If the authenticated IdP token succeeds but the `employee_reference` is not found or is suspended in the SCM database:
54+
### Alternative Flow B: Unlinked Organization Member Reference
55+
* If the authenticated IdP token succeeds but the `identity_reference` is not found or is suspended in the SCM database:
5656
* The backend aborts the login process.
5757
* Saves a security warning inside the immutable access audit logs.
5858
* Returns a `403 Forbidden` response explaining that the corporate account is not active on the SCM portal.

src/ums-workspace/docs/en/02-architecture/bounded-context-map.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ graph TD
9090
- IdP configuration data (owned by Config Context)
9191

9292
**Integration Contracts (Published Language):**
93-
- `UserRegisteredEvent { userId, organizationId, branchId, employeeReference }`
93+
- `UserRegisteredEvent { userId, organizationId, branchId, identityReference }`
9494
- `UserSuspendedEvent { userId, tenantId }`
9595
- `OrganizationCreatedEvent { tenantId, idpStrategy }`
9696

src/ums-workspace/docs/en/03-adrs/0031-abstract-identity-domain-subject.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
Currently, the User Management System (UMS) and the extended SCM domain implicitly use the "Employee" concept as the fundamental unit that holds permissions, interacts with systems, and authenticates against the Identity Provider (IdP).
1212

1313
This approach shows critical technical and functional coupling:
14-
* **Database and APIs:** The use of the `employee_reference` property as mandatory backend validation after OAuth (JWT) token exchange.
15-
* **Domain Events:** The `UserRegisteredEvent` directly carries the `employeeReference` field.
14+
* **Database and APIs:** The use of the `identity_reference` property as mandatory backend validation after OAuth (JWT) token exchange.
15+
* **Domain Events:** The `UserRegisteredEvent` directly carries the `identityReference` field.
1616
* **Business Rules:** Validations that require the reference to match internal Human Resources systems exclusively.
1717

1818
### ⚠️ Identified Problem
1919
With the introduction of B2B business flows (such as **Use Case 12 / FS-10: External Access Approval Workflow**), the business now requires provisioning access to identities that **are not employees** of the host company (e.g., third-party drivers, forklift operators hired by suppliers, external auditors, B2B clients).
20-
Forcing these individuals to have an "Employee Reference" forces "polluting" the HR database with external personnel, blocks agile provisioning, and creates semantic inconsistency in the domain.
20+
Forcing these individuals to have an "Organization Member Reference" forces "polluting" the HR database with external personnel, blocks agile provisioning, and creates semantic inconsistency in the domain.
2121

2222
---
2323

@@ -29,7 +29,7 @@ The technical and functional implementation guidelines are:
2929

3030
1. **Semantic Abstraction:** The domain will no longer validate "Employees." Instead, it will validate a `Subject` that has a role and a contextual relationship with a `Tenant` through their `Organization`.
3131
2. **Replacement of References:**
32-
* The `employee_reference` field in the database and API contracts will be renamed/migrated to `external_identity_reference` or simply `identity_reference`.
32+
* The `identity_reference` field in the database and API contracts will be renamed/migrated to `external_identity_reference` or simply `identity_reference`.
3333
* The `identity_reference_type` field (`HR_ID`, `VENDOR_CODE`, `GOVERNMENT_ID`, `PARTNER_REF`) will be added to give semantic context to the external reference.
3434
3. **Provisioning Responsibility by Organization:** The external user's organization becomes the entity responsible for their personnel's lifecycle, mediated by formal request flows approved by a corporate Sponsor (complying with the federated delegation principle).
3535

@@ -43,10 +43,10 @@ classDiagram
4343
class User {
4444
+UUID id
4545
+String email
46-
+String employee_reference
46+
+String identity_reference
4747
}
4848
class HR_System {
49-
+validateEmployee(employee_reference)
49+
+validateEmployee(identity_reference)
5050
}
5151
User --> HR_System : Tight Coupling
5252
```
@@ -95,9 +95,9 @@ To ensure operational continuity and not break backward compatibility:
9595

9696
1. **Coexistence Phase (Dual Read/Write):**
9797
* Enrich the users table with the `identity_reference` and `reference_type` fields (temporarily nullable).
98-
* The .NET 8 API will read from `employee_reference` if present, but will save to both fields for existing records.
98+
* The .NET 8 API will read from `identity_reference` if present, but will save to both fields for existing records.
9999
2. **API Deprecation Phase:**
100-
* Mark the `employee_reference` claim in the JWT payload as `[Obsolete]` or in the process of deprecation, but keeping it in the token for compatibility with legacy microservices.
100+
* Mark the `identity_reference` claim in the JWT payload as `[Obsolete]` or in the process of deprecation, but keeping it in the token for compatibility with legacy microservices.
101101
* Inject the new unified claim `sub_ref` (Subject Reference).
102102
3. **Purging Phase:**
103-
* Once 100% of the services consume `sub_ref`, execute a database script to remove the obsolete column `employee_reference`.
103+
* Once 100% of the services consume `sub_ref`, execute a database script to remove the obsolete column `identity_reference`.

src/ums-workspace/docs/en/04-artifacts/enterprise-iam-ums-specification.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ In this reference scenario, a **SCM Transportation Analyst** initiates a session
2727
### Use Case: Contextual Authentication & Multi-Tenant Graph Synthesis
2828
* **Primary Actor**: SCM Transportation Analyst.
2929
* **Target System**: SCM Route Planner.
30-
* **Preconditions**: User is registered in UMS and holds a valid employee reference; SCM Route Planner and Callao Terminal are registered in the UMS.
30+
* **Preconditions**: User is registered in UMS and holds a valid identity reference; SCM Route Planner and Callao Terminal are registered in the UMS.
3131
* **Postconditions**: Session established with dual cryptographically rotated tokens and a contextual, branch-restricted JSON authorization graph.
3232

3333
### Variations and Exception Paths
34-
* **Variation A: Federated Identity Provider (Azure AD/Okta)**: Gateway delegates credential verification to the external corporate IdP via SAML2/OIDC. SCM local database is bypassed for credential verification, and user is mapped using `employee_reference` claims.
34+
* **Variation A: Federated Identity Provider (Azure AD/Okta)**: Gateway delegates credential verification to the external corporate IdP via SAML2/OIDC. SCM local database is bypassed for credential verification, and user is mapped using `identity_reference` claims.
3535
* **Variation B: Multi-Factor Authentication (MFA)**: If the tenant enforces adaptive MFA based on IP range, the analyst is prompted for WebAuthn (Passkeys) verification before the UMS authorization graph call is triggered.
3636
* **Exception 1: Missing Tenant Context**: If the request lacks `tenant_id` or `branch_id`, the API returns a `400 Bad Request` with error code `ERR_MISSING_CONTEXT`, aborting graph resolution.
3737
* **Exception 2: Authorization Graph Not Found**: If the user authenticates successfully but holds no active profile assignments for the Callao branch, the API returns a `403 Forbidden` with error code `ERR_ZERO_PERMISSIONS`.
@@ -124,7 +124,7 @@ Authorization: Bearer m2m_token_gateway_abc123
124124
"principal": {
125125
"user_id": "usr_analyst_callao_098",
126126
"email": "analyst@logisticscorp.com",
127-
"employee_reference": "EMP-PERU-998"
127+
"identity_reference": "EMP-PERU-998"
128128
},
129129
"context": {
130130
"tenant_id": "tenant_logistics_corp",

src/ums-workspace/docs/en/04-artifacts/enterprise-multitenant-governance-report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
After an exhaustive analysis of the UMS ecosystem, we have identified a **rigid structural coupling** in the original design that negatively impacts the platform's SaaS evolution.
1212

1313
### Key Architectural Findings
14-
1. **Identity Coupling (Employee vs. Subject):** The dependence on `employee_reference` as a mandatory field assumes an internal employment relationship. This blocks B2B scenarios where the user is an external supplier, a third-party driver, or an integration bot (M2M) lacking a record in the corporate HR database.
14+
1. **Identity Coupling (Employee vs. Subject):** The dependence on `identity_reference` as a mandatory field assumes an internal employment relationship. This blocks B2B scenarios where the user is an external supplier, a third-party driver, or an integration bot (M2M) lacking a record in the corporate HR database.
1515
2. **Orphaned Software Assets:** Systems (SCM, WMS, ERP) and their components (Menus, APIs) currently operate in a "flat" global catalog. There is no explicit definition of who is the logical owner of the resource and under what conditions a third party (Tenant) can consume it.
1616
3. **Ambiguous Security Boundaries:** The permission model focuses on the "What" (action) but not on "Who owns the object." This violates **Zero Trust** principles where the Organization should be the physical and logical frontier for every bit of information.
1717

@@ -60,7 +60,7 @@ Systems and applications explicitly belong to an organization.
6060
## 🚀 5. Incremental Transition Strategy
6161

6262
1. **Phase 01 (Foundation):** Implement the Organizations table as a boundary and associate 100% of current users with the "Root Organization."
63-
2. **Phase 02 (Decoupling):** Migrate from `employee_reference` to `identity_reference` (Agnostic Subject). Inject `X-Org-Context` in the API Gateway.
63+
2. **Phase 02 (Decoupling):** Migrate from `identity_reference` to `identity_reference` (Agnostic Subject). Inject `X-Org-Context` in the API Gateway.
6464
3. **Phase 03 (Enforcement):** Activate RLS policies in PostgreSQL for all domain tables.
6565
4. **Phase 04 (Federation):** Enable the B2B Access Request module so external organizations can autonomously request access to internal systems.
6666

src/ums-workspace/docs/en/04-artifacts/ums-configuration-platform-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The UMS must allow per-tenant (and optionally per-system) configuration of one o
5252
"config_secret_ref": "vault://ums/secrets/logisticscorp/azure_client_secret",
5353
"scopes": ["openid", "profile", "email"],
5454
"user_claim_mapping": {
55-
"employee_reference": "employeeId",
55+
"identity_reference": "identityId",
5656
"email": "upn"
5757
}
5858
},

src/ums-workspace/docs/es/01-requirements/conceptual-data-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ erDiagram
5252
- `organization_id` (UUID, FK): Owning tenant organization.
5353
- `email` (string, Unique): Corporate email address.
5454
- `password_hash` (string, **Nullable**): Populated **only** when the Internal Bcrypt Strategy adapter is active for the organization. `NULL` when authentication is delegated to an external IdP.
55-
- `employee_reference` (string): External unique ID linking to corporate HR/ERP records.
55+
- `identity_reference` (string): External unique ID linking to corporate HR/ERP records.
5656
- `status` (enum): `ACTIVE`, `SUSPENDED`, or `TERMINATED`.
5757
- `created_at` (timestamp): Record creation timestamp.
5858

src/ums-workspace/docs/es/01-requirements/functional-stories/fs-01-user-authentication.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Este documento especifica el flujo de transacciones, los actores y las estrategi
1010
| :--- | :--- |
1111
| **Nombre** | Autenticación de Usuario vía IdP Externo |
1212
| **Actor Principal** | Usuario Corporativo SCM |
13-
| **Precondiciones** | El usuario está registrado en la base de datos de ULPMS y posee una referencia válida de empleado de RRHH. |
13+
| **Precondiciones** | El usuario está registrado en la base de datos de ULPMS y posee una referencia de identidad válida. |
1414
| **Postcondiciones** | La sesión se establece en la aplicación SCM y se devuelve una cookie segura HTTP-Only. |
1515

1616
---
@@ -30,7 +30,7 @@ sequenceDiagram
3030
User->>IdP: Ingresar Credenciales Corporativas
3131
IdP-->>Web: Redirigir con Auth Code
3232
Web->>API: Intercambiar Auth Code
33-
Note over API: Verificar Token y Claim de Empleado
33+
Note over API: Verificar Token y Claim de Identidad
3434
API-->>Web: Configurar Cookie de Sesión HTTP-Only
3535
```
3636

@@ -39,8 +39,8 @@ sequenceDiagram
3939
2. El cliente web redirige al usuario al endpoint de autorización del Proveedor de Identidad externo configurado (Keycloak/Azure AD) utilizando el **Flujo de Código de Autorización OAuth 2.0 con PKCE**.
4040
3. El usuario se autentica exitosamente utilizando sus credenciales corporativas en el portal del IdP.
4141
4. El IdP redirige el navegador de vuelta al portal SCM con un Código de Autorización de un solo uso autorizado.
42-
5. El backend SCM intercambia el Código de Autorización con el IdP por un Token de Acceso firmado criptográficamente (JWT) que contiene los claims del empleado.
43-
6. El backend verifica la firma RS256 del token y valida que la `employee_reference` coincida con un registro de empleado activo en la base de datos local de SCM.
42+
5. El backend SCM intercambia el Código de Autorización con el IdP por un Token de Acceso firmado criptográficamente (JWT) que contiene los claims de identidad.
43+
6. El backend verifica la firma RS256 del token y valida que la `identity_reference` coincida con un registro de identidad activa en la base de datos local de SCM.
4444
7. El sistema inicializa la sesión del usuario, inyecta el contexto del tenant y devuelve una cookie de sesión segura, HTTP-Only y SameSite=Strict.
4545

4646
---
@@ -51,8 +51,8 @@ sequenceDiagram
5151
* Si falla la conexión a Keycloak/Azure AD, el Gateway SCM intercepta el error de tiempo de espera (timeout).
5252
* El sistema muestra una página de credenciales de respaldo segura que permite a los Administradores de TI autorizados iniciar sesión utilizando credenciales locales de emergencia de ULPMS, mientras que a los operadores estándar se les solicita reintentar.
5353

54-
### Flujo Alternativo B: Referencia de Empleado no Vinculada
55-
* Si el token del IdP autenticado es exitoso pero no se encuentra la `employee_reference` o está suspendida en la base de datos SCM:
54+
### Flujo Alternativo B: Referencia de Miembro de Organización no Vinculada
55+
* Si el token del IdP autenticado es exitoso pero no se encuentra la `identity_reference` o está suspendida en la base de datos SCM:
5656
* El backend aborta el proceso de inicio de sesión.
5757
* Guarda una advertencia de seguridad dentro de los registros de auditoría de acceso inmutables.
5858
* Devuelve una respuesta `403 Forbidden` explicando que la cuenta corporativa no está activa en el portal SCM.

src/ums-workspace/docs/es/02-architecture/bounded-context-map.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
> ?? **Nota de Arquitectura:** Este documento se encuentra actualmente en su versión original (Inglés) y está programado para traducción oficial en la hoja de ruta.
1+
> ?? **Nota de Arquitectura:** Este documento se encuentra actualmente en su versin original (Ingls) y est programado para traduccin oficial en la hoja de ruta.
22
33
# 🗺️ Bounded Context Map — User Management System (UMS)
44

@@ -92,7 +92,7 @@ graph TD
9292
- IdP configuration data (owned by Config Context)
9393

9494
**Integration Contracts (Published Language):**
95-
- `UserRegisteredEvent { userId, organizationId, branchId, employeeReference }`
95+
- `UserRegisteredEvent { userId, organizationId, branchId, identityReference }`
9696
- `UserSuspendedEvent { userId, tenantId }`
9797
- `OrganizationCreatedEvent { tenantId, idpStrategy }`
9898

0 commit comments

Comments
 (0)