Skip to content

feat: Validate Proxy-Authorization credentials (#52)#59

Open
homilclaw wants to merge 1 commit intomainfrom
feat/proxy-auth-validation
Open

feat: Validate Proxy-Authorization credentials (#52)#59
homilclaw wants to merge 1 commit intomainfrom
feat/proxy-auth-validation

Conversation

@homilclaw
Copy link
Collaborator

Summary

Add optional Proxy-Authorization validation so the Home Node can verify that inbound requests come from an authorized Gateway.

Changes

  • app/config.py: New PROXY_AUTH_USERNAME and PROXY_AUTH_PASSWORD settings (default empty)
  • app/proxy_handler.py:
    • _proxy_auth_required() — returns 407 response
    • _parse_basic_auth() — decodes Proxy-Authorization: Basic <b64> headers
    • Auth check in handle_client() before CONNECT/HTTP forward dispatch
  • Backward compatible: when either setting is empty, auth is skipped

How it works

  1. Gateway embeds credentials in node's endpoint_url: https://user:pass@1.2.3.4:9090
  2. Gateway extracts and sends Proxy-Authorization: Basic <b64> to Home Node
  3. Home Node validates against configured SR_PROXY_AUTH_USERNAME / SR_PROXY_AUTH_PASSWORD
  4. Returns 407 on mismatch

Tests

  • 22 new tests in tests/test_proxy_auth.py
  • 210 total tests passing

Depends on: PR #58 (Request-ID tracing)

Closes #52

- Add PROXY_AUTH_USERNAME and PROXY_AUTH_PASSWORD to Settings (optional)
- When both are configured, validate Proxy-Authorization: Basic header
- Return 407 Proxy Authentication Required on mismatch
- Backward compatible: skip validation if either setting is empty
- Parse Basic auth (case-insensitive scheme, supports colons in password)
- 22 new tests, 210 total passing

Closes #52
Base automatically changed from feat/request-id-tracing to main March 12, 2026 03:59
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