-
Notifications
You must be signed in to change notification settings - Fork 0
Auth Module Overview
simitben edited this page Apr 11, 2026
·
1 revision
Define a secure, maintainable App-based authentication and authorization model for SimBiz 6 API V3.
- This page is a design specification for the App-based auth hardening workstream.
- Runtime source implementation is tracked separately under
APIV3-020.
- V3 public token endpoint is
POST /api/v3/auth/token(source-code/simbiz6/modules/simantz/apiv3/module.php). - Token issuance validates
client_id + client_secretand app/org scope before issuing app token (source-code/simbiz6/modules/simantz/apiv3/AuthAppController.php). - Request authentication supports app-token context and permission/org checks in guard/middleware (
source-code/simbiz6/apiv3/Auth/TokenGuard.php,source-code/simbiz6/apiv3/Auth/PermissionGuard.php). - Router currently supports only
requiresAuthboolean per route, with no permission key metadata (source-code/simbiz6/apiv3/Core/Router.php).
- Authenticate external integrations as Apps, not shared user secrets.
- Issue opaque DB-backed bearer tokens scoped to app + organization access.
- Enforce authorization in two layers:
- route permission (resource-action)
- organization access (allowed org list)
- Support secret lifecycle operations:
- create
- rotate (with optional grace)
- revoke
- audit
- Provide introspection endpoint so callers can read current app profile, scopes, org access, and token expiry.
| Component | Responsibility |
|---|---|
App Registry |
Store app identity, status, client_id, metadata |
Secret Manager |
Hash, rotate, revoke app secrets with history |
Token Service |
Issue/revoke opaque tokens and enforce expiry |
Permission Catalog |
Define resource-action permissions independent from URL |
Route Permission Map |
Map each route key to one permission code |
Org Access Control |
Restrict app usage to assigned organizations |
Audit Log |
Track auth/security events for traceability |
| Decision Point | Recommendation | Reason |
|---|---|---|
| 1) Permission by raw path vs resource-action | Use resource-action permission codes + route map |
Stable even when URL path changes |
| 2) App to organization linking | Use explicit app-org mapping table | Supports single-org and multi-org apps safely |
| 3) Secret regeneration model | Create new secret version; old secret can enter grace | Safer rotation without sudden outage |
| 4) Old secret validity during rotation | Default grace 24h, configurable, allow immediate revoke |
Operationally safe + security control |
| 5) Token type | Opaque DB-backed token | Immediate revoke, simpler in PHP 7.3 legacy stack |
| 6) Immediate revoke enforcement | Validate token against DB on every request | Real-time suspension/revocation behavior |
| 7) Permission inspection endpoint |
GET /api/v3/auth/me + GET /api/v3/auth/me/permissions
|
Third-party can verify granted access quickly |
| 8) Check enforcement location | Central auth middleware/guard before controller | Avoid duplicated checks in every controller |
| Criteria | Opaque DB Token | JWT |
|---|---|---|
| Immediate revoke/suspend | Strong (DB status check) | Weak without blacklist |
| Rotation complexity | Low | Medium/high (key mgmt + invalidation complexity) |
| Legacy PHP 7.3 fit | Strong | Medium |
| Operational debugging | Strong (lookup in DB) | Medium |
| Stateless performance | Medium | Strong |
Recommendation: use opaque DB-backed token for SimBiz 6 V3, prioritizing enforceable revoke/suspend and maintainability.
- Read
Authorization: Bearer <token>. - Hash token and find active token session.
- Validate app status (
ACTIVE). - Resolve route key and required permission.
- Validate app has required permission.
- Resolve target organization from request payload/query.
- Validate organization is assigned to app.
- Attach
auth_context(app_id,app_code,token_id,organization_id, permissions) to request. - Continue to module controller.
- App status:
ACTIVE,SUSPENDED,REVOKED,EXPIRED - Secret status:
ACTIVE,GRACE,REVOKED,EXPIRED - Token status:
ACTIVE,REVOKED,EXPIRED
- V3 endpoint is
/api/v3/auth/token. -
x-uidis not required for external app authentication.