Skip to main content

Overview

Zarna uses a two-part authentication system:
  1. JWT Authentication for API access
  2. OAuth 2.0 for third-party service integration (Gmail, Outlook, Drive)

JWT Authentication Flow

Login Flow

JWT Token Structure

Header:
Payload:
Signature:

API Request Flow

Token Validation

Token Refresh

OAuth 2.0 Flow (Gmail/Outlook)

Authorization Code Flow

State Token Security

State Validation

Row Level Security (RLS)

Firm-Level Isolation

All database queries automatically filter by firm:

Implementation

Session Management

Frontend Session Handling

Security Best Practices

Development: localStorage acceptable Production: HttpOnly cookies recommended
  • Access token: 24 hours
  • Refresh token: 7 days
  • Rotate refresh tokens on each use
Always use HTTPS in production:
  • Prevents token interception
  • Encrypts all data in transit
  • Required for secure cookies
Whitelist specific origins only:

Next Steps

OAuth Setup

Set up Gmail and Outlook OAuth

API Security

API security best practices

Backend Auth

Backend authentication implementation

System Overview

Overall system architecture