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
/tokenendpoint withgrant_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
- Email & Password
- Magic Links
- OTP (SMS)
- OAuth
- Admin Login
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:| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | Time until window resets (seconds) |
Error Handling
Authentication errors follow a consistent format:| Code | Description |
|---|---|
400 | Bad Request - Invalid request format |
401 | Unauthorized - Invalid or missing credentials |
403 | Forbidden - Insufficient permissions |
429 | Too Many Requests - Rate limit exceeded |
JWT Token Structure
Access tokens are JWTs containing user information:Best Practices
Token Storage
Token Storage
- Store access tokens in memory or secure storage
- Store refresh tokens in secure, httpOnly cookies when possible
- Never store tokens in localStorage in production
Token Refresh
Token Refresh
- Implement automatic token refresh before expiration - Handle refresh token rotation properly - Implement proper error handling for expired refresh tokens
Security
Security
- Always use HTTPS in production - Implement proper CORS policies - Validate tokens on every request - Log authentication events for security monitoring
Error Handling
Error Handling
- Handle authentication errors gracefully
- Implement proper logout on token expiration
- Provide clear error messages to users