Skip to main content

Authentication Flow

End-to-End Auth Architecture

Token Types

TokenIssuerContentsLifetime
Cognito ID TokenAWS CognitoUser identity claims1 hour
App Access TokenIdentity ServiceUser + tenant + roles1 hour
Refresh TokenIdentity ServiceToken refresh grant30 days
API KeyOrganization ServiceMachine authenticationConfigurable

Guard Chain

Every authenticated request passes through guards in order:

  1. JwtAuthGuard - Validates JWT signature and expiry
  2. TenantGuard - Extracts tenant context from token
  3. RolesGuard (optional) - Checks @Roles() decorator
  4. PermissionsGuard (optional) - Checks @Permissions() decorator