MATIH Platform is in active MVP development. Documentation reflects current implementation status.
6. Identity & Access Management
Authentication
Overview

Authentication Overview

Production - AuthController - 7 endpoints

The authentication subsystem manages user identity verification through credential-based login, self-service registration, email verification, password reset, token refresh, and logout. All authentication endpoints are served by the AuthController at the /api/v1/auth path prefix.


Authentication Endpoints

MethodEndpointDescriptionAuth Required
POST/api/v1/auth/loginAuthenticate with email/passwordNo
POST/api/v1/auth/mfa/verifyComplete MFA challengeNo
POST/api/v1/auth/registerSelf-service registrationNo
POST/api/v1/auth/verify-emailVerify email addressNo
POST/api/v1/auth/resend-verificationResend verification codeNo
POST/api/v1/auth/refreshRefresh access tokenNo
POST/api/v1/auth/logoutRevoke refresh tokenNo

Authentication Flow Overview

The login flow supports both simple credential-based authentication and multi-factor authentication:

Client                  AuthController          AuthenticationService
  |                           |                          |
  |--- POST /auth/login ----->|                          |
  |                           |--- login() ------------->|
  |                           |                          |--- Validate credentials
  |                           |                          |--- Check account locked?
  |                           |                          |--- Check MFA enabled?
  |                           |                          |
  |                           |                    [MFA Enabled?]
  |                           |                     /         \
  |                           |                   Yes          No
  |                           |                    |            |
  |                           |<-- MfaChallengeResponse    AuthResponse
  |<-- 200 (MFA challenge) ---|                          |
  |                           |                          |
  |--- POST /auth/mfa/verify->|                          |
  |                           |--- verifyMfa() --------->|
  |                           |                          |--- Verify code
  |                           |                          |--- Generate tokens
  |<-- 200 (AuthResponse) ----|<-- AuthResponse ---------|

AuthResponse Structure

All successful authentication operations return an AuthResponse:

{
  "accessToken": "eyJhbGciOiJIUzI1NiJ9...",
  "refreshToken": "eyJhbGciOiJIUzI1NiJ9...",
  "tokenType": "Bearer",
  "expiresIn": 900,
  "user": {
    "id": 1,
    "email": "user@example.com",
    "firstName": "Jane",
    "lastName": "Smith",
    "displayName": "Jane Smith",
    "tenantId": "00000000-0000-0000-0000-000000000001",
    "roles": ["ROLE_USER"],
    "emailVerified": true
  }
}
FieldTypeDescription
accessTokenStringJWT access token for API authentication
refreshTokenStringJWT refresh token for obtaining new access tokens
tokenTypeStringAlways "Bearer"
expiresInLongAccess token validity in seconds
userUserInfoAuthenticated user profile

Security Considerations

  • IP Address Extraction: All authentication endpoints extract the client IP from X-Forwarded-For or RemoteAddr for audit logging and anomaly detection
  • User Agent Tracking: The User-Agent header is captured for device fingerprinting and session correlation
  • Account Lockout: Failed login attempts are tracked per user. After exceeding the configured threshold (default: 5 attempts), the account is locked for a configurable duration (default: 30 minutes)
  • Soft Delete: Deleted users are filtered out by the @SQLRestriction("deleted = false") annotation, making them invisible to authentication queries

Section Pages

PageDescription
Login FlowCredential validation, MFA challenge, JWT token generation
RegistrationSelf-service registration with email verification
Email VerificationVerification code flow and resend logic
Password ResetForgot password and admin reset flows
Refresh TokensToken rotation, family tracking, reuse detection
LogoutSession termination and token revocation