GRPC-tunnel: fix non-bearer auth credential schemes - #133
Merged
Conversation
`token` emitted `Bearer`, `raw` emitted `raw ` instead of the bare token, and `basic` with a pre-encoded token dropped it and sent `Basic Og==` — base64 of ":", an empty credential. A scheme is now supported exactly when `authHeaderBuilders` has a builder for it, so the set and the behaviour cannot drift. An unrecognized scheme warns and sends no header, which is what snyk-broker's authHeader() does with one. The bodies match snyk-broker's lib/common/utils/auth-header.ts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 28, 2026
aszarama
approved these changes
Aug 28, 2026
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.
Stack 1/3 — base
main. Independent of the other two; reviewable and mergeable on its own.The bug
Three of the four auth schemes sent the wrong credential:
tokenBearer <t>Token <t>rawraw <t><t>— no prefixbasicwith a pre-encodedtokenBasic Og==(base64 of":", an empty credential)The
basiccase is the sharp one: a rule carrying an already-encodeduser:passpair — the shape Azure Repos uses — dropped it and authenticated as nobody.The fix
A scheme is supported exactly when
authHeaderBuildershas a builder for it, so the supported set and the behaviour cannot drift. They were previously a set in one file and aswitchin another, raw string literals in both — a scheme in the set with no case sends no credential while claiming support, and a case with no set entry warns about itself while working fine.The builder bodies match snyk-broker's
lib/common/utils/auth-header.ts.An unrecognized scheme now warns and sends no header, which is what the broker's
authHeader()does with one — it returnsundefined. Previously it invented<scheme> <token>.Scope
auth.gois new;applyAuthmoves out ofrouter.gowhole. Nothing else inrouter.gois touched, and no signature changes — this is why it sits at the bottom of the stack rather than tangled into the wildcard work.Test plan
router_auth_test.gocovers each scheme's exact header, case-insensitive scheme lookup,basicpreferring username/password when both are present, and an unknown scheme sending nothing.TestEveryDeclaredAuthSchemeBuildsACredentialiteratesauthHeaderBuilders, so a scheme added without a test fails the build rather than shipping untested.test/conformance/auth_schemes.jsonencodes the same cases as transport-agnostic fixtures.go test ./server/snykbroker/... ./common/...green.🤖 Generated with Claude Code