Skip to main content

Authentication Overview

The Hokusai Authentication Service provides centralized identity, API key management, and access control for the entire Hokusai platform. It handles user registration, wallet-based authentication (SIWE), API key lifecycle, team management, usage tracking, and billing.

Architecture

Key Concepts

Authentication Methods

Hokusai supports two authentication methods:

  1. API Keys — The primary mechanism for service-to-service and application access. Keys are cryptographically generated, BCrypt-hashed, scoped, and service-bound.
  2. Sign-In with Ethereum (SIWE) — Wallet-based authentication for Web3 users. Returns a JWT token for session-based access to protected endpoints.

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 two platform services:

Service IDDescription
predictionThe prediction/inference API
platformThe Hokusai web application, ML platform, and general platform access
info

The website and ml-platform service types have been consolidated into platform. Existing keys with the old types continue to work.

Organizations

Users can create organizations to manage team access. Organizations provide:

  • Role-based access control (RBAC) — Owner, Admin, Developer, and Viewer roles
  • Organization-scoped API keys — Keys that belong to the org, not individual users
  • Invitation system — Invite team members via email with a specific role
  • Audit logging — Track all actions taken within the organization

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
Registration3 endpointsRegister, verify email, check status
Key Management5 endpointsCreate, list, get, revoke, and rotate API keys
Validation2 endpointsValidate API keys and JWT tokens
SIWE Auth2 endpointsWallet challenge and signature verification
Organizations12 endpointsOrg CRUD, members, invitations, org API keys, audit logs
Usage & Billing4 endpointsTrack usage, get statistics, billing info, and aggregates
Health3 endpointsService health, readiness, and metrics

Authentication Model

The auth service uses a three-tier authentication model:

  1. Admin Token — A server-side bearer token required for key management and registration admin operations. 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.
  3. JWT Tokens — Session tokens issued after SIWE wallet authentication. Validated via the /api/v1/tokens/validate endpoint. Used for organization management and user-facing features.
info

The API key validation and JWT token validation endpoints are both public — they do not require an admin token. This allows any Hokusai service to validate credentials independently.

Next Steps