Skip to main content

Overview

Zarna uses JWT (JSON Web Tokens) for API authentication with industry-standard security practices.

Token Security

Token Structure

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.    # Header (algorithm, type)
eyJzdWIiOiJ1c2VyLWlkIiwiZmlybV9pZCI6... # Payload (claims)
SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c  # Signature

Secure Storage

localStorage is acceptable for development:
localStorage.setItem('access_token', token)
Risks: XSS vulnerabilities can access localStorage

Best Practices

Always use HTTPS to prevent token interception
Access tokens: 24 hours max Refresh tokens: 7 days max
Use 256+ bit random secrets:
openssl rand -base64 64
Issue new refresh token on each use, invalidate old ones
Check expiration, issuer, audience on every request

OWASP Top 10 Compliance

  • A01 Broken Access Control: RLS + JWT
  • A02 Cryptographic Failures: HTTPS + encrypted secrets
  • A03 Injection: Parameterized queries
  • A05 Security Misconfiguration: Secure defaults
  • A07 Identification & Auth Failures: JWT + OAuth

Next Steps