Skip to content

Authentication Flows

This section documents the various authentication flows in GrydAuth. Each flow includes detailed sequence diagrams showing the interaction between components.

Overview

GrydAuth supports multiple authentication scenarios to handle different user states and requirements:

Flow Decision Tree

The following diagram shows how GrydAuth determines which flow to execute:

100% 💡 Use Ctrl + Scroll para zoom | Arraste para navegar

Quick Reference

FlowTriggerToken TypeExpiration
Standard LoginTenant resolved (single/preferred/default)Tenant (access) tokenJwtSettings:ExpirationMinutes — default 10, range 1–15
First LoginIsFirstLogin or MustChangePasswordGlobal Token2 minutes (hardcoded, single-use)
Switch TenantMultiple tenants, no default/preferred matchGlobal Token2 minutes (hardcoded, single-use)
MFA ChallengeTenant MFA policy requires itMFA-pending tokenShort-lived, no refresh token
Refresh TokenAccess token expiredNew Tenant tokenResets expiration; refresh token rotates (7-day default)
LogoutUser actionN/AImmediate, global (all sessions)

Common Components

All flows share these core components:

Security Service

Handles:

  • Password verification (Argon2id)
  • Password strength validation
  • Failed attempt tracking
  • Account lockout

JWT Service

Generates and validates:

  • Access tokens (short-lived)
  • Refresh tokens (long-lived)
  • Global tokens (tenant selection / first login)

Token Claims

Every token carries exactly one token_type claim (access / refresh / global / mfa_pending) — see canonical token type. Access tokens additionally carry:

json
{
  "sub": "user-id-guid",
  "token_type": "access",
  "tenant_id": "tenant-id-guid",
  "tenant_name": "Acme Corp",
  "role": ["Admin", "User"],
  "permission": ["users:read", "users:write"],
  "token_version": 1,
  "group_id": "parent-group-tenant-id",
  "group_name": "Holding Sul",
  "iat": 1751462400,
  "exp": 1751463000
}

role / permission, not roles / permissions

The underlying JWT claim types are singular (role, permission), repeated once per value. group_id/group_name only appear for child tenants in a hierarchical/group tenant.

Additional Flows

Already implemented, documented separately:

  • Multi-Factor Authentication - TOTP + recovery codes, per-tenant step-up policy
  • Reset Password - Self-service password recovery (request-password-reset / reset-password)
  • Social Login - OAuth via POST /api/v1/auth/social-login

Not yet implemented:

  • WebAuthn / Passkeys (FIDO2) - reserved MFA factor type, planned for a future release
  • API Key Authentication - Service-to-service auth

Released under the MIT License.