fix: pool gateway transports and add OAuth token redaction#100
Merged
Conversation
added 6 commits
June 4, 2026 16:17
Middleware can now call gateway.RegisterSecret(value) in init() to declare secrets that should be redacted from gateway logs. This covers template-baked tokens that aren't available via env vars or rewriter interfaces. Applied to both existing middlewares: - github-pat: registers the PAT token - telegram: registers the bot token Gateway main.go collects secrets from 3 sources: 1. Env-var backed (auth-header rewriter config) 2. Runtime secrets (OAuth SecretProvider interface) 3. Middleware-declared (gateway.Secrets())
Remove collectSecrets() — AuthHeaderRewriter now implements SecretProvider directly, returning the raw env var value. Secret collection is now two clean sources: 1. Rewriters implementing SecretProvider (auth-header, OAuth) 2. Middleware-declared via gateway.RegisterSecret() No more special-casing rewriter types in main.go.
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.
Closes #85, closes #83
Transport Pooling (#85)
forwardRequest()was creating a newhttp.Transportper request, killing connection pooling. Added async.Maptransport cache keyed by serverName — transports are created once and reused.OAuth Token Redaction (#83)
collectSecrets()didn't handle OAuth tokens. AddedSecretProviderinterface to the mitm package.OAuthRewriterimplements it, exposing the cached access token. Gateway main iterates built rewriters forSecretProviderand adds tokens to the redaction list.Tests
TestHandler_TransportReuse— verifies same transport returned for same hostTestOAuthRewriter_ImplementsSecretProvider— verifies token appears in Secrets()