Skip to content

feat: add interactive pre-authentication for login-gated applications#271

Open
amichajlowski wants to merge 5 commits intoKeygraphHQ:mainfrom
amichajlowski:feat/interactive-auth
Open

feat: add interactive pre-authentication for login-gated applications#271
amichajlowski wants to merge 5 commits intoKeygraphHQ:mainfrom
amichajlowski:feat/interactive-auth

Conversation

@amichajlowski
Copy link
Copy Markdown

Summary

  • Add shannon auth command — new CLI command that opens a browser session for manual pre-authentication before a scan. Allows users to log in interactively, then saves the authenticated session state for reuse across all pipeline agents
  • Extend config schema with interactive login type — adds an interactive login type alongside existing form/SSO/API/basic auth types, with a dedicated config block for browser launch settings and session persistence
  • Thread session ID into prompts — passes the authenticated Playwright session ID through the prompt pipeline so agents pick up the live session rather than starting unauthenticated
  • Add INTERACTIVE section to login instructions — expands the shared login instructions prompt with guidance for agents on how to detect and reuse an interactively pre-authenticated session
  • Add interactive authentication guide — documents the full pre-auth workflow, config options, and usage patterns for login-gated targets

Add 'interactive' to LoginType for OAuth/Google Sign-In flows where
the user authenticates manually in a browser before scanning.
Credentials are optional for this login type (enforced via if/then
in JSON Schema). Config parser and sanitizer handle missing credentials
gracefully.
New BEGIN:INTERACTIVE section in login-instructions.txt tells agents
how to restore a pre-authenticated session from auth-state.json using
localStorage injection and cookie setting via Playwright evaluate.

Thread sessionId from ActivityInput through AgentExecutionInput and
PromptVariables so the {{SESSION_ID}} placeholder resolves to the
workspace name, letting agents locate auth-state.json on disk.

Update buildLoginInstructions() to handle interactive type (no
credentials, no login_flow) and buildAuthContext() for missing
credentials.
New `shannon auth -c config.yaml [-w workspace]` command opens a visible
Chromium browser for the user to complete OAuth/SSO login (e.g., Google
Sign-In + 2FA). After the success condition is met, captures the browser
storage state (cookies + localStorage) to auth-state.json in the workspace.

- pre-auth.ts: Standalone Playwright module with dynamic import (Playwright
  is an optional peer dependency, not bundled)
- auth.ts: CLI command with minimal YAML parser to extract login_url and
  success_condition without adding js-yaml as a dependency
- index.ts: Register auth command with arg parsing
- start.ts: Detect and log existing auth-state.json in workspace
Add docs/interactive-auth.md covering the full workflow: prerequisites,
config format, auth command, multi-repo setup, and troubleshooting.

Update .gitignore to exclude configs/ (user config files with potential
credentials), .env.*, and audit-logs/ from version control.
Dynamic ESM import cannot resolve bare directory paths for globally
installed packages. Switch to createRequire which handles node_modules
resolution correctly, with fallback to global npm root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant