Authentication provider
MUZE uses better-auth for authentication. It is configured as an Express middleware handler mounted directly on the NestJS application at/api/auth. better-auth stores sessions and user records in the same PostgreSQL database via @better-auth/prisma-adapter.
Key design decisions
Session cookie configuration
In production, better-auth sets these cookie attributes:SameSite: Lax is used.
Auth endpoints (better-auth built-in)
All auth endpoints live under/api/auth (outside the /api/v1 prefix):
Session validation flow
Every authenticated request goes throughSessionGuard:
The SessionGuard calls authService.getSession(request.headers) which internally calls better-auth’s getSession() with the request headers. This queries the Session table in PostgreSQL to validate the token.
Password management
- Passwords are hashed by better-auth using industry-standard algorithms (bcrypt by default)
- Password reset emails contain a token that links to
/reset-password?token=... - When a password is reset via the invite flow, the user’s
emailVerifiedflag is set totrue - There are no password complexity requirements enforced beyond what better-auth provides by default
What MUZE does not support
- No multi-factor authentication (MFA)
- No OAuth / social login
- No SSO / SAML / OIDC
- No API key authentication
- No service-to-service authentication (all API calls are browser-initiated)
- No session rotation on privilege escalation
- No concurrent session limits