Skip to main content

API Authentication

SDD Classification: L3-Technical Authority: Engineering Team Review Cycle: Quarterly
Materi uses JWT (JSON Web Tokens) for secure, stateless authentication. This guide covers all authentication methods, token management, and security best practices.

Authentication Flow Overview


JWT Token Structure

Access Token Claims

Token Properties


Authentication Methods

Method 1: Email/Password Login

Response:

Method 2: OAuth 2.0 Authorization Code

Step 1: Redirect to Authorization
Step 2: Exchange Code for Tokens

Method 3: Client Credentials (Server-to-Server)


OAuth Scopes


Token Refresh

Access tokens expire after 15 minutes. Use refresh tokens to obtain new access tokens:
Response:
Refresh tokens are rotated on each use. The old refresh token becomes invalid immediately. Store the new refresh token securely.

Automatic Token Refresh Pattern


Token Revocation

Revoke Current Token

Revoke All User Sessions


SSO Integration

Supported Providers

SAML 2.0 Configuration

SAML Service Provider Metadata:

Security Best Practices

Token Storage Recommendations

Never store tokens in:
  • LocalStorage (XSS vulnerable)
  • SessionStorage (XSS vulnerable)
  • URL parameters
  • Log files

Rate Limiting for Auth Endpoints


Public Key Endpoint

Validate JWT tokens locally using the public key:
Response:
Key Rotation Policy:
  • Keys rotate every 90 days
  • Dual-key overlap for 7 days
  • Cache JWKS for maximum 5 minutes

Authentication Errors



Document Status: Complete Version: 2.0