Skip to content

fix(auth): bind callback server to loopback - #13

Open
Kamilgulzar wants to merge 1 commit into
zidsa:mainfrom
Kamilgulzar:fix/auth-callback-loopback
Open

Kamilgulzar wants to merge 1 commit into
zidsa:mainfrom
Kamilgulzar:fix/auth-callback-loopback

Conversation

@Kamilgulzar

Copy link
Copy Markdown

Summary

The authentication callback server currently binds to every network interface when vitrin login starts. A request to the machine's LAN address can therefore supply a token to the CLI session during authentication.

Bind the shared authentication listener explicitly to 127.0.0.1, keeping callbacks local for both the CLI and TUI login flows. Add standalone regression tests that exercise the real HTTP listener without opening a browser or writing credentials.

Fixes #10.

Validation

Tested on Windows with Node.js 22.13.1:

  • Build passes: npm run build.
  • All 15 security regression tests pass, with no skips.
  • GET and POST requests through a non-loopback IPv4 interface are refused without saving a token; a control HTTP server is reachable on that same interface.
  • Localhost, default port 4444, custom ports, GET query callbacks, JSON/form POST callbacks, and POST query callbacks work.
  • Listener shutdown, missing tokens, token-save failures, CORS preflight, authentication timeout, and occupied-port rejection are covered.
  • Temporarily restoring the original all-interface listener causes the network regression test to fail because the request reaches the callback.
  • Regression-test formatting and git diff --check pass.

Run the standalone regression tests after building (Node.js 22.3+ required for experimental module mocking):

node --experimental-test-module-mocks --test tests/security/auth-listener.test.mjs

The network test requires a non-loopback IPv4 interface; it reports a skip when none is available. The default-port test requires port 4444 to be free. These tests run separately from the existing Jest suite.

Existing check failures and limits

  • npm test: all five existing suites fail before executing tests because Jest parses import.meta in tests/setup.ts outside an ES module.
  • npm run lint: ESLint 9 cannot find a flat configuration; the repository provides .eslintrc.js.
  • Network validation uses this machine's LAN address from the same machine. A separate-device test and live Partner Dashboard sign-in were not performed.

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.

Local Auth Server Exposed to Network

1 participant