Skip to main content
The Gateway API provides authentication endpoints for admin login and guest token generation.

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 bucket metacogna-accounts: Path: auth/admins/{username}.json Structure:

Password Hashing

Passwords are hashed using SHA-256:
During login, the gateway:
  1. Retrieves {salt, hash} from R2
  2. Computes SHA256(salt + providedPassword)
  3. Compares computed hash with stored hash

Token Usage

Include the token in the Authorization header:

Route Access Rules

Error Codes

Code Examples

Admin Login

Guest Token Generation

Authenticated Request