🔐 Authentication & Authorization

Authentication Overview

Ever Gauzy uses a comprehensive authentication system built on Passport.js with multiple strategies, supporting both traditional and social login flows.

Authentication Flow

Diagram; its source is available below
Diagram source
graph LR
    A["Client<br/>(Browser / Desktop)"] --> B["Login Request"]
    B --> C["Passport Strategy<br/>(Validate)"]
    C --> D["JWT Token Issued"]
    D --> E["Stored Client Side"]

Login Methods

MethodStrategyDescription
Email + Passwordpassport-localTraditional credentials
Magic Sign-InCustomPasswordless via email code
Google OAuthpassport-google-oauth20Sign in with Google
GitHub OAuthpassport-github2Sign in with GitHub
Facebook OAuthpassport-facebookSign in with Facebook
Twitter OAuthpassport-twitterSign in with Twitter
LinkedIn OAuthpassport-linkedin-oauth2Sign in with LinkedIn
Microsoft OAuthpassport-microsoftSign in with Microsoft

Token Types

TokenPurposeLifetime
Access Token (JWT)API authenticationShort-lived (configurable)
Refresh TokenObtain new access tokensLong-lived (configurable)
Password Reset TokenOne-time password resetShort-lived
Email Verification TokenConfirm email ownershipShort-lived
Invite TokenUser/candidate invitationConfigurable expiry
Magic CodePasswordless login5 minutes

Security Features

Password Hashing

Passwords are hashed using bcrypt with a configurable salt rounds:

const hashedPassword = await bcrypt.hash(password, 12);

JWT Configuration

Configure JWT behavior via environment variables:

JWT_SECRET=your-secret-key
JWT_TOKEN_EXPIRATION_TIME=86400          # 24 hours (seconds)
JWT_REFRESH_TOKEN_SECRET=your-refresh-secret
JWT_REFRESH_TOKEN_EXPIRATION_TIME=604800  # 7 days (seconds)

Rate Limiting

Authentication endpoints are rate-limited to prevent brute-force attacks:

THROTTLE_ENABLED=true
THROTTLE_TTL=60000      # 1 minute window
THROTTLE_LIMIT=60000    # Max requests per window

Account Lockout

After multiple failed login attempts, accounts can be temporarily locked.

Guard Architecture

Guards are applied per-controller or per-route:

// Public route (no auth required)
@Public()
@Post('login')
async login() { /* ... */ }

// Authenticated + specific role
@UseGuards(TenantPermissionGuard, RoleGuard)
@Roles(RolesEnum.ADMIN)
@Get('admin-only')
async adminOnly() { /* ... */ }

// Authenticated + specific permission
@UseGuards(TenantPermissionGuard, PermissionGuard)
@Permissions(PermissionsEnum.EMPLOYEES_EDIT)
@Post('employee')
async createEmployee() { /* ... */ }

Edit this page

Copyright © 2023-Present Ever Co. LTD.Docs by Sourcey