feat: add Bearer token API key authentication#2
Open
onurgoz wants to merge 1 commit into
Open
Conversation
- Add --api-key CLI flag and OCULOS_API_KEY env var support - Auto-generate cryptographically secure key (oculos_<hex>) if none provided - Axum middleware layer validates Authorization: Bearer header on all routes - Support ?token= query param for browser WebSocket connections - Dashboard login screen with localStorage persistence and 401 auto-logout - Constant-time key comparison to prevent timing attacks - Fail-closed design (500 if auth layer misconfigured) - MCP mode bypasses auth (stdin/stdout, no network) - Recorder exports include auth headers in generated code - README: auth section with usage examples, curl commands updated
aadya940
added a commit
to aadya940/oculos
that referenced
this pull request
Apr 5, 2026
slim find_ui_elements and add sense to prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--api-key <KEY>CLI flag andOCULOS_API_KEYenv var for API authenticationoculos_<32-byte hex>) when none is providedAuthorization: Bearer <KEY>on all HTTP endpoints (/windows/**,/interact/**,/hwnd/**,/health,/ws)?token=<KEY>query parameter (since browser WS API cannot send custom headers)--mcp) bypasses auth entirely (stdin/stdout, no network involved)Changed files
Cargo.tomlrand = "0.8"dependencysrc/auth.rssrc/main.rs--api-keyCLI arg, env var, wiringsrc/api/mod.rssrc/api/ws.rsstatic/index.htmlREADME.mdTest plan
cargo buildcompiles without errors on all 3 platforms--api-key→ random key printed to console--api-key mykey→ "Using provided API key" loggedOCULOS_API_KEY=mykey→ same behaviorcurl http://localhost:7878/windows→ 401 Unauthorizedcurl -H "Authorization: Bearer <key>" http://localhost:7878/windows→ 200 OK?token=and receives events--mcpmode works without any auth prompts