feat(proxy): configurable intercept scope and unmatched policy#263
Open
rishabhraj36 wants to merge 4 commits into
Open
feat(proxy): configurable intercept scope and unmatched policy#263rishabhraj36 wants to merge 4 commits into
rishabhraj36 wants to merge 4 commits into
Conversation
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.
Description
Introduces a single
proxy.modesetting onGlobalConfigthat combines two orthogonal axes into one knob:connected(build the route table only from active connections, today's behavior) vsconfigured(build it from every configured provider, so hosts can be guarded before login).allow(let unmatched requests or requests with no credentials pass through untouched) vsdeny(block with HTTP 403 and aproxy_denyaudit event).The four resulting modes are
connected_allow(default, unchanged from today),connected_deny,configured_allow, andconfigured_deny.Implementation notes:
ProxyConfigPydantic model onGlobalConfigwith aLiteralmode field.AuthService.proxy_mode()returns the current mode;proxy_routes()switches its source set based on the scope half of the mode.GET /proxy/modedaemon endpoint +AuthsomeApiClient.proxy_mode()so the mitmproxy addon reads the mode at router-build time over the sameProxyClientprotocol it already uses — no directGlobalConfigcoupling, no daemon restart required when the mode changes.AuthProxyAddonnow distinguishes three outcomes and emits matching audit events:proxy_inject(matched + creds available),proxy_miss/proxy_deny reason=no_match(no route), andproxy_no_credentials/proxy_deny reason=no_credentials(route matched but credential resolution failed).Motivation and Context
Closes #260.
Today the proxy only intercepts hosts belonging to active connections and silently passes everything else through. That makes two reasonable workflows impossible:
Folding both knobs into one explicit
modekeeps the surface area small while making the intercept/block matrix obvious from a single config field.How Has This Been Tested?
Automated:
uv run pytest— full suite green, including the existingtests/proxy/test_proxy.pycases (updated to mockproxy_mode()) and new coverage forconnected_denyblocking unmatched hosts.uv run ruff check— clean.uv run ty check src/— clean.Types of changes
The default mode (
connected_allow) preserves today's behavior, so no migration is needed.Checklist: