Skip to main content

Overview

Strike Auth Service uses JWT (JSON Web Tokens) for authentication, providing a secure and stateless way to authenticate users. The service supports multiple authentication methods and follows OAuth 2.0 standards where applicable.

Authentication Flow

1

User Registration/Login

Users can register or login using various methods (email/password, magic links, OAuth, etc.)
2

Token Issuance

Upon successful authentication, the service issues an access token and refresh token
3

API Requests

Include the access token in the Authorization header for authenticated requests
4

Token Refresh

Use the refresh token to obtain new access tokens when they expire

Token Types

Access Token

  • Purpose: Authenticate API requests
  • Lifetime: 1 hour (3600 seconds)
  • Format: JWT with user claims
  • Usage: Include in Authorization: Bearer <token> header

Refresh Token

  • Purpose: Obtain new access tokens
  • Lifetime: 30 days (configurable)
  • Format: Opaque string
  • Usage: Send to /token endpoint with grant_type=refresh_token

Service Role Key

  • Purpose: Admin operations and server-to-server communication
  • Lifetime: No expiration (until rotated)
  • Format: Opaque string
  • Usage: Include in Authorization: Bearer <service-role-key> header

Authentication Methods

Traditional authentication with email and password.

Security Headers

All authenticated requests should include the access token in the Authorization header:

Rate Limiting

Authentication endpoints include rate limiting to prevent abuse:

Error Handling

Authentication errors follow a consistent format:
Common authentication error codes:

JWT Token Structure

Access tokens are JWTs containing user information:

Best Practices

  • Store access tokens in memory or secure storage
  • Store refresh tokens in secure, httpOnly cookies when possible
  • Never store tokens in localStorage in production
  • Implement automatic token refresh before expiration - Handle refresh token rotation properly - Implement proper error handling for expired refresh tokens
  • Always use HTTPS in production - Implement proper CORS policies - Validate tokens on every request - Log authentication events for security monitoring
  • Handle authentication errors gracefully
  • Implement proper logout on token expiration
  • Provide clear error messages to users

Example Implementation

Here’s a complete example of implementing authentication in JavaScript:

Next Steps

User Management

Learn about user lifecycle and profile management

Security Concepts

Understand security features and best practices

Integration Guides

Step-by-step implementation guides

API Reference

Detailed API documentation