Skip to main content

API Authentication

JJHub supports two authentication modes:
  • Session authentication for browser-based login flows
  • Bearer token authentication for CLI, CI, and other programmatic clients

Session Authentication

Session-based login flows establish authentication with cookies instead of a bearer token. Successful session login responses set:
  • jjhub_session for the authenticated session
  • __csrf for CSRF protection on session-authenticated write requests

Sign in with Key

Sign in with Key uses a challenge-response flow:
  1. GET /auth/key/nonce
  2. Sign a structured message with the returned nonce
  3. POST /auth/key/verify
  4. Receive a JJHub session via Set-Cookie

GET /auth/key/nonce

Returns a single-use nonce for the next signature attempt.
Notes:
  • Nonces are single-use
  • Nonces expire after about 10 minutes

POST /auth/key/verify

Submit a signed message and signature to create a JJHub session. The signed message must include the configured JJHub auth domain on the first line and the server-issued nonce. On hosted JJHub, the message domain is jjhub.tech even though the API endpoint host is api.jjhub.tech.
A successful response also includes Set-Cookie headers for jjhub_session and __csrf. Common failure modes:
  • 400 invalid JSON or missing message / signature
  • 401 invalid signature or invalid / expired nonce
  • 403 account suspended or not permitted by closed-alpha access controls
  • 415 request body is not application/json

GitHub OAuth

JJHub also supports browser-based login via GitHub OAuth.

GET /auth/github

Starts the OAuth flow, stores a CSRF state verifier in a cookie, and redirects the browser to GitHub.
Notes:
  • The response is a redirect, not JSON
  • The jjhub_oauth_state cookie must be preserved through the callback request

GET /auth/github/callback

GitHub redirects the browser back to JJHub with code and state query parameters:
Notes:
  • The callback returns a redirect after creating the session
  • On success, JJHub clears the temporary jjhub_oauth_state cookie
  • The default post-login redirect is /
Common failure modes:
  • 400 missing code or state, or GitHub code exchange failed
  • 401 invalid or replayed OAuth state
  • 403 account suspended or not permitted by closed-alpha access controls
  • 409 GitHub account email is already in use by another JJHub account

Bearer Tokens

Programmatic API clients can authenticate with a bearer token:

Generating Tokens

Via CLI:
Via API:

Token Format

All tokens are prefixed with jjhub_ and are SHA-256 hashed before storage. Tokens are shown once at creation time.

Error Responses

HTTP 401 is returned for missing or invalid tokens. HTTP 403 is returned for insufficient scope.