Skip to main content

Authentication Overview

The Hokusai Authentication Service provides centralized API key management for the entire Hokusai platform ecosystem. It handles key creation, validation, rotation, usage tracking, and billing across all Hokusai services.

Architecture

Key Concepts

API Keys

API keys are the primary authentication mechanism for all Hokusai services. Each key is:

  • Cryptographically generated — 32 random characters with an environment prefix
  • BCrypt hashed — only the hash is stored; the full key is shown once at creation
  • Scoped — keys can be restricted to specific operations
  • Service-bound — each key is associated with a specific service (website, prediction, or platform)

Environments

Keys are prefixed by environment to prevent accidental cross-environment usage:

EnvironmentPrefixUse Case
Productionhk_live_Live traffic, real billing
Testhk_test_Integration testing, staging
Developmenthk_dev_Local development

Services

The auth service manages keys for three platform services:

Service IDDescription
websiteThe Hokusai web application
predictionThe prediction/inference API
platformThe ML platform and training infrastructure

Rate Limits

Each API key has a configurable rate limit (default: 1,000 requests/hour). Rate limits are enforced per key, not per IP address. You can set limits between 10 and 100,000 requests per hour when creating a key.

Scopes

Scopes provide fine-grained access control. When creating a key, you can specify which operations it is allowed to perform (e.g., predict, train, read). If no scopes are set, the key has full access within its service.

Endpoint Summary

The auth service exposes the following endpoint groups:

GroupEndpointsDescription
Key Management5 endpointsCreate, list, get, revoke, and rotate API keys
Validation1 endpointValidate API keys and check permissions
Usage & Billing4 endpointsTrack usage, get statistics, billing info, and aggregates
Health3 endpointsService health, readiness, and metrics

Authentication Model

The auth service uses a two-tier authentication model:

  1. Admin Token — A server-side bearer token required for key management operations (create, list, revoke, rotate, view stats/billing). Set via the ADMIN_TOKEN environment variable.
  2. API Keys — Client-facing keys used by applications to authenticate with Hokusai services. Validated via the /api/v1/keys/validate endpoint.
info

The validation endpoint itself is public — it does not require an admin token. This allows any Hokusai service to validate incoming API keys without sharing the admin secret.

Next Steps