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_sessionfor the authenticated session__csrffor CSRF protection on session-authenticated write requests
Sign in with Key
Sign in with Key uses a challenge-response flow:GET /auth/key/nonce- Sign a structured message with the returned nonce
POST /auth/key/verify- Receive a JJHub session via
Set-Cookie
GET /auth/key/nonce
Returns a single-use nonce for the next signature attempt.- 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 isjjhub.tech even though the API endpoint host is api.jjhub.tech.
Set-Cookie headers for jjhub_session and __csrf.
Common failure modes:
400invalid JSON or missingmessage/signature401invalid signature or invalid / expired nonce403account suspended or not permitted by closed-alpha access controls415request body is notapplication/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.- The response is a redirect, not JSON
- The
jjhub_oauth_statecookie must be preserved through the callback request
GET /auth/github/callback
GitHub redirects the browser back to JJHub withcode and state query parameters:
- The callback returns a redirect after creating the session
- On success, JJHub clears the temporary
jjhub_oauth_statecookie - The default post-login redirect is
/
400missingcodeorstate, or GitHub code exchange failed401invalid or replayed OAuth state403account suspended or not permitted by closed-alpha access controls409GitHub 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:Token Format
All tokens are prefixed withjjhub_ and are SHA-256 hashed before storage. Tokens are shown once at creation time.