The Authentication subsystem handles OAuth2 tokens (Laravel Passport), Keycloak realm code exchange, self-service API key provisioning, and user identity contexts.
Issues a Bearer access token for client applications or backend services.
POST /oauth/token{
"grant_type": "client_credentials",
"client_id": "9d8e72c0-...",
"client_secret": "secret_key_...",
"scope": ""
}
{
"grant_type": "password",
"client_id": "9d8e72c0-...",
"client_secret": "secret_key_...",
"username": "developer@dsroma.com",
"password": "StrongPassword123!",
"scope": ""
}
200 OK){
"token_type": "Bearer",
"expires_in": 31536000,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIs...",
"refresh_token": "def50200..."
}
POST /oauth/token/refresh{
"grant_type": "refresh_token",
"refresh_token": "def50200...",
"client_id": "9d8e72c0-...",
"client_secret": "secret_key_..."
}
/v1/auth/user)Returns authenticated user details, authorized companies, active roles, and granular permissions.
GET /v1/auth/user/my-profileAuthorization: Bearer <token>, x-app-stage, x-app-uid200 OK){
"success": true,
"message": "Perfil de usuario obtenido",
"data": {
"id": 42,
"uuid": "8f1a23b4-5678-4321-abcd-ef0123456789",
"name": "Admin Usuario",
"email": "admin@dsroma.com",
"companies": [
{
"id": 1,
"name": "ROMA DISTRIBUCIONES S.A.C.",
"ruc": "20100000001",
"is_default": true
}
],
"roles": ["ADMINISTRATOR", "SALES_SUPERVISOR"],
"permissions": ["orders.create", "orders.approve", "kardex.view"]
}
}
goal_me login)Lightweight identity + active transactional company assignments (type = T, company and assignment status = A). Does not load company-scoped permissions or module master data (sellers, branches).
GET /v1/auth/users/mobile-profileAuthorization: Bearer <token>, x-app-stage, x-app-uid| Param | Default | Description |
|---|---|---|
includeGlobalPermissions |
false |
When true, includes global permission_codes (legacy clients). |
200 OK)data is MobileUserEssentialResource:
| Field | Description |
|---|---|
active_assigned_companies |
UserAssignedCompanyEssentialResource (company_id, name, short_name, type, status). |
companies |
Matching CompanyResource list for the picker / offline cache. |
roles_list |
Global role names (support / diagnostics). |
Client fallback: GET /v1/auth/users/my-companies?includeProperties=true if assignments are empty.
Company-scoped access after the user selects (or resumes) a company.
GET /v1/auth/users/company-profilecompanyId (required), includeProperties (default true), includeSellers (default false), includeBranches (default false)200 OK)data is a UserAssignedCompanyResource:
| Field | Description |
|---|---|
module_codes |
Mobile modules (TVendo, TDoy, …) from company roles. |
permission_codes |
Gadmin permission hashes scoped to companyId. |
company_roles / company_permissions |
Pivot metadata from user_companies. |
sellers / branches |
Only when includeSellers / includeBranches are true. |
Stage 3 (module bootstrap) uses module APIs (e.g. GET /v1/pre-sale/master-data/{id}/sellers for TVendo).
Optional paths for multitenant session hub. v1 endpoints remain supported.
| Method | Path | Description |
|---|---|---|
GET |
/v1/auth/v2/tenants |
Active transactional assignments. Each row’s id / goal_company_id is the company id (use for /app/{id} and POST .../context). user_company_id is the user_companies pivot row. |
POST |
/v1/auth/v2/tenants/{companyId}/context |
Same payload as company-profile (query/body: includeSellers, includeBranches, includeProperties). |
GET |
/v1/auth/v2/session/bootstrap |
Optional companyId: without → user + tenants; with → user + tenants + company context. |
Headers: Authorization, x-app-stage, x-app-uid.
Mobile flag: AUTH_TENANT_API_V2=true in .env (defaults to v1).
Web SPA (goal-front): same stage-2/tenant semantics via src/services/tenant/tenant-session-service.js. Optional VITE_AUTH_TENANT_API_V2=true in Vite env (defaults to v1: GET /auth/users/my-companies + GET /auth/users/company-profile).
| Stage | Web default (v1) | After activateTenant |
|---|---|---|
| 1 User | GET /v1/auth/users/web-profile (optional ?essential=true slim payload) |
Global permissions until stage 2 |
| 2 Company | GET /v1/auth/users/company-profile?companyId= |
permission_codes scoped via jwt-auth-context.applyCompanyContext |
| Tenants list | GET /v1/auth/users/my-companies |
Validated on resume (localStorage.companyId + /app/:id URL) |
Self-service API keys for automated integrations and background daemons.
GET /v1/auth/user/my-api-keysAuthorization: Bearer <token>Creates a Personal Access Token with optional IP/domain restriction metadata. The raw token string is displayed only once upon generation.
POST /v1/auth/user/generate-api-keyAuthorization: Bearer <token>{
"name": "SAP B1 Sync Service",
"ip_address": "192.168.1.50",
"allowed_domains": ["integrations.roma.com"],
"expires_at": "2027-12-31 23:59:59"
}
201 Created){
"success": true,
"message": "API Key generada exitosamente. Guarde el token en un lugar seguro.",
"data": {
"token_id": "a948e23f...",
"name": "SAP B1 Sync Service",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIs...",
"expires_at": "2027-12-31 23:59:59"
}
}
DELETE /v1/auth/user/api-keys/{tokenId}Authorization: Bearer <token>GET /v1/auth/user/oauth-clientsAuthorization: Bearer <token>