$ cd ../projects ⌃O / -
elwin@sytadel:~$ ▋
auth-api
Multi-tenant identity provider: Sytadel's trust plane, also usable standalone.
- NestJS
- TypeORM
- PostgreSQL
- WebAuthn
- JWT
## problem
Every app that grows needs multi-tenant identity done right: users, tenants, roles, sessions, token rotation and passkeys. Reimplementing it per service leads to inconsistencies and security holes.
- In a microservice suite there's an extra question: who owns the truth of identity?
- If every service keeps its own copy of tenants and roles, sooner or later they diverge.
## architecture
A self-contained IdP that only needs PostgreSQL. A tenant → membership → role model (OWNER / ADMIN / MEMBER) issuing tenant-scoped JWTs.
- The single source of truth for tenants and memberships: other services have NO local foreign keys to identity.
- They resolve it through an internal server-to-server directory, protected by a shared secret + HMAC (not publicly exposed).
- Public API (login / refresh / logout / logout-all / me) + internal endpoints (resolve tenants and memberships, provisioning).
- Usable as the IdP of your own app even if you don't adopt the rest of the suite.
## technical decisions
- Pinned HS256 JWT (no alg:none or algorithm confusion), with issuer, audience and expiry verified and separate secrets for access and refresh.
- Refresh-token rotation with reuse detection: if a refresh is reused, the whole token family is revoked.
- Passkeys / WebAuthn resistant to account enumeration.
- Idempotent provisioning: takes a signed idempotencyKey; retries from the same caller and key return the same result, and reusing the key with different data is rejected.
- The service-account secret is encrypted at rest with AES-256-GCM.
- The schema is owned by migrations (migrationsRun on boot, synchronize OFF).
## results
- The only service in the suite that runs fully independently — portable to any app as an IdP.
- Served as the base to extract the JWT-verification logic into the @elwinernst/nest-auth npm package.