Endpoints
POST /auth/login
Authenticate an admin user and receive a JWT token.Admin credentials are stored in R2 bucket (
metacogna-accounts) with SHA-256 hashed passwords.Request Body
Response (Success)
Response (Error)
Authentication Flow
POST /auth/guest
Generate a guest token for unauthenticated access to certain routes.Request Body
Response
JWT Token Structure
Tokens are signed JWTs with the following claims:Default Values
- Issuer:
gateway.metacogna.ai - Audience:
metacogna-clients - Algorithm:
HS256 - Expiration:
1h(configurable)
Credential Storage
Admin credentials are stored in R2 bucketmetacogna-accounts:
Path: auth/admins/{username}.json
Structure:
Password Hashing
Passwords are hashed using SHA-256:- Retrieves
{salt, hash}from R2 - Computes
SHA256(salt + providedPassword) - Compares computed hash with stored hash
Token Usage
Include the token in theAuthorization header:
Route Access Rules
Error Codes
Code Examples
Admin Login
Guest Token Generation
Authenticated Request
Related Documentation
- Routing API - Route configuration
- Shared Package - JWT implementation details