Skip to main content

Overview

Jean uses token-based authentication to secure HTTP and WebSocket connections. Authentication can be optionally enabled/disabled via server configuration.

Token Generation

Tokens are cryptographically random 32-byte strings encoded with base64url:
Example token: Kj8vN2Qw1xYzM4P7R6Sf9T3Uc0Vd5We8Xf1Yg4Zh7Ai2Bj

Server Configuration

Authentication is configured when starting the HTTP server:
string
required
The authentication token (generated automatically)
boolean
default:true
Whether authentication is enforced. Set to false to disable authentication.

Authentication Methods

HTTP Query Parameter

Provide the token as a query parameter:

WebSocket Query Parameter

Include the token when upgrading to WebSocket:

Endpoints

Validate Token

boolean
required
true if the token is valid, false otherwise
boolean
Whether authentication is enabled on the server. Only present when token_required = false.
string
Error message when token validation fails. Only present on failure.
Success Response (200)
Success Response (No Auth Required)
Error Response (401)

WebSocket Authentication

Connection Flow

  1. Upgrade Request: Client sends HTTP GET to /ws?token=YOUR_TOKEN
  2. Validation: Server validates the token (if token_required = true)
  3. Upgrade: On success, connection is upgraded to WebSocket
  4. Event Stream: Client receives real-time events

JavaScript Example

Python Example

Token Validation

The server uses constant-time comparison to prevent timing attacks:

Security Considerations

The API currently uses unencrypted HTTP/WebSocket. For production deployments:
  • Use a reverse proxy with TLS (nginx, Caddy)
  • Enable localhost_only mode for local development
  • Consider implementing HTTPS support in the server
  • Store tokens securely (environment variables, secure config files)
  • Never commit tokens to version control
  • Rotate tokens periodically
  • Use different tokens for different environments
When localhost_only = false, the server is accessible on the LAN:
  • Ensure firewall rules are configured properly
  • Use strong, random tokens
  • Consider IP allowlisting
Setting token_required = false disables all authentication:
  • Only use in trusted environments
  • Never expose to the internet without authentication
  • Useful for internal tools and testing

Error Codes

Next Steps

API Overview

Learn about the API architecture

Projects API

Start managing projects