Overview
Rexec provides multiple authentication methods to suit different use cases:- JWT Authentication - Session-based authentication with configurable duration
- OAuth 2.0 (PipeOps) - Federated authentication with PKCE flow
- API Tokens - Long-lived tokens for programmatic access
- Guest Access - Temporary 50-hour sessions without authentication
- Multi-Factor Authentication (MFA) - TOTP-based 2FA for enhanced security
Authentication Methods
JWT Authentication
JWT tokens are issued after successful authentication and include user identity, tier, and subscription status. Token Claims:- Guest users: 50 hours (fixed)
- Authenticated users: Configurable (default 90 days)
- Custom duration: Set via
session_duration_minutesin user profile
Using JWT Tokens
Include the JWT token in theAuthorization header:
Guest Login
Create a temporary 50-hour session without OAuth authentication.Username (2-30 characters, alphanumeric with underscores/hyphens)
Optional email for returning guest recognition
JWT token valid for 50 hours
Token expiration in seconds (180000 = 50 hours)
True if email matched an existing guest session
Guest sessions are limited to 50 hours and have restricted resource limits. For production use, authenticate via OAuth.
OAuth 2.0 Flow (PipeOps)
Rexec uses OAuth 2.0 with PKCE for secure federated authentication through PipeOps.Step 1: Get Authorization URL
PipeOps authorization URL with PKCE challenge
CSRF protection state parameter (stored in secure cookie)
Step 2: User Authorization
Redirect the user to theauth_url. After authorization, PipeOps redirects back to:
Step 3: Token Exchange
The callback endpoint automatically:- Validates the state parameter
- Exchanges the authorization code for an access token
- Fetches user info from PipeOps
- Creates or updates the user account
- Returns a JWT token
Security: OAuth uses PKCE (Proof Key for Code Exchange) to prevent authorization code interception attacks. The code verifier and state are stored in secure HTTP-only cookies.
Multi-Factor Authentication (MFA)
Rexec supports TOTP-based MFA (compatible with Google Authenticator, Authy, etc.) with backup codes.Setup MFA
Initiate MFA setup and receive a secret for your authenticator app.Base32-encoded TOTP secret (store securely)
OTP URL for QR code generation (otpauth:// URI)
Verify and Enable MFA
Verify the TOTP code to enable MFA and receive backup codes.TOTP secret from setup endpoint
6-digit TOTP code from authenticator app
10 one-time backup codes (save securely!)
MFA Login Flow
When MFA is enabled, the OAuth callback returns an intermediate MFA token:- Complete OAuth flow normally
- If MFA is enabled, receive a 10-minute MFA token
- Prompt user for TOTP code
- Complete MFA login to receive full auth token
6-digit TOTP code or 8-character backup code
Disable MFA
Regenerate Backup Codes
User Profile
Retrieve the authenticated user’s profile and resource limits.Update Profile
Username (2-50 characters)
IP whitelist (CIDR notation supported:
192.168.1.0/24)Session duration in minutes (default 129600 = 90 days)
IP Whitelisting: When
allowed_ips is set, only requests from those IPs/subnets are allowed. Empty array clears the whitelist.Session Management
Rexec tracks active sessions for security and supports single-session mode.Session Features
- Session Tracking: All logins create a tracked session with IP and user agent
- Session Revocation: Tokens with revoked sessions are rejected
- Single Session Mode: Optionally limit user to one active session
- Screen Lock: Enforce screen lock after inactivity (blocks old tokens)
- Last Seen: Sessions update last seen timestamp on each request
Session ID in Token
JWT tokens include asid claim with the session ID. The auth middleware:
- Validates the session exists and isn’t revoked
- Updates last seen timestamp
- Enforces screen lock if enabled
WebSocket Authentication
For WebSocket connections, pass the token via theSec-WebSocket-Protocol header:
Error Responses
401 Unauthorized
- Token expired
- Invalid signature
- Session revoked
- User not found
- MFA required
403 Forbidden
423 Locked
Security Best Practices
Token Storage: Store JWT tokens securely. For web apps, use
httpOnly cookies. For mobile/desktop, use secure storage (Keychain, Keystore).Token Rotation: Tokens are reissued on profile updates. Update your stored token when you receive a new one.
IP Whitelisting: For sensitive environments, restrict access by IP using the
allowed_ips profile field.MFA Recovery: Store backup codes securely offline. If you lose access to your authenticator app, backup codes are your only recovery method.
Related Endpoints
- API Tokens - Manage long-lived API tokens
- Sessions - View and revoke active sessions
- Authentication Guide - MFA and security settings