Repository navigation
Conversation
snowkide
force-pushed
the
feat/forwarded-client-id-auth
branch
from
November 3, 2026 10:57
3cb7068 to
3599b4b
Compare
snowkide
force-pushed
the
feat/forwarded-client-id-auth
branch
from
November 3, 2026 11:23
3599b4b to
b59945a
Compare
snowkide
force-pushed
the
feat/forwarded-client-id-auth
branch
from
November 4, 2026 14:31
b59945a to
cd967de
Compare
The Http.ReceivedRequest span recorded r.URL.String() verbatim, so a secret, token, JWT or SIWE signature passed as ?secret=, ?token=, ?jwt= or ?signature= was exported to the tracing backend. Replace those values with REDACTED; other query parameters and the path are kept as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…callers When eRPC runs behind an API gateway or reverse proxy that already authenticates callers, the gateway typically forwards the authenticated client's id in a request header. The new forwardedClientId strategy trusts that header as the user id, so per-client rate-limit budgets, method scoping and the user metric label work without duplicating the gateway's key store in eRPC. The strategy is only active when configured and is offered every HTTP or WebSocket request that carries its header, in declaration order: - header: header name, default X-Client-Id - allowedProxies: only trust the header from these direct TCP peers (the socket address, not the X-Forwarded-For client IP); a startup warning is logged when it is empty - allowedIds: optional allowlist, also bounds user label cardinality - rateLimitBudget: budget attached to the authenticated user A header with several values (a proxy that appends instead of overwriting) is rejected, as are ids that are empty, longer than 256 bytes, or contain whitespace, commas or non-ASCII characters. AuthPayload now carries the request headers and remote address so that strategies can read their own transport inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Many clients and gateways send an API key as ?apikey=, an X-Api-Key or apikey header, or (wallets and SDKs that only accept a single RPC URL) as the URL path itself. The secret and database strategies gain additionalLocations, empty by default, to also accept the secret from: - apikeyQuery: the ?apikey= query parameter - apikeyHeader: the X-Api-Key or apikey header - path: the URL path as a single segment (https://host/<secret>), only on a domain alias that preselects project, architecture and chain so the path is not used for routing; /admin, /healthcheck and /metrics are never treated as secrets These locations are consulted only when none of the standard ones supplied a secret, and never change the extracted credential type, so a request carrying only one of them still reaches a network strategy as before. A strategy ignores a secret from a location it does not list; unknown location names fail validation. A path is only read as a secret when the auth config serving the request (the project's, or healthCheck.auth for GET healthchecks) lists path. Such a path is replaced with /REDACTED in the http.url span attribute and the CORS metrics' path label, and ?apikey= values are redacted from http.url like ?secret=. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
snowkide
force-pushed
the
feat/forwarded-client-id-auth
branch
from
November 5, 2026 13:52
cd967de to
5291495
Compare
This branch has not been deployed
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.
Two opt-in auth additions for deployments where eRPC sits behind an API gateway or is used by clients that only take a single RPC URL, plus a tracing fix. Nothing changes for existing configurations.
Commits (can be split into three PRs; 3 depends on 1):
fix(tracing): redact credential query parameters fromhttp.url.Http.ReceivedRequestrecordedr.URL.String()verbatim, so?secret=,?token=,?jwt=and SIWE?signature=values were exported to the tracing backend. They are now replaced withREDACTED; other parameters and the path are unchanged.feat(auth):forwardedClientIdstrategy. When a gateway already authenticates callers and forwards the client id in a header, eRPC uses that header as the user id, so per-client rate-limit budgets, method scoping and theuserlabel work. Inactive unless configured.header(defaultX-Client-Id),allowedIds,rateLimitBudget.allowedProxies: checked against the direct TCP peer, not X-Forwarded-For (separate fromserver.trustedIPForwarders, which only resolves the client IP). A startup warning is logged when it is empty.feat(auth): opt-in secret locations for thesecretanddatabasestrategies viaadditionalLocations(empty by default), consulted only when no standard location supplied a secret:apikeyQuery(?apikey=),apikeyHeader(X-Api-Key/apikey),path(https://host/<secret>, only on a domain alias that fixes project, architecture and chain).networkstrategies behave as before. Unknown location names fail validation.http.urland the CORS metric label, when the auth config serving the request listspath(healthCheck.authfor GET requests).?apikey=is redacted like?secret=.Security note:
forwardedClientIdtrusts a header. Enable it only behind a proxy that strips or overwrites that header from clients, and restrictallowedProxiesto that proxy.Notes for review:
forwardedClientIdauthenticates (budgets, method scoping andallowClientDirectivesapply), unliketrustUserIdHeader, which only labels.databasestrategy logsapiKeyat debug/warn/error level, and thesecretstrategy's comparison is not constant-time.Docs:
config/auth,operation/tracing.Verification
Based on fork
main@ f97c9f6 (erpc/erpc0.5.0 @ 204f98c). Build, vet and auth tests pass at each commit.go build ./...andgo vet ./auth ./common ./erpcare clean;gofmt -lon touched files is clean.go test ./auth ./telemetry ./common: ok;go test -race ./auth: ok.go test ./erpc -run 'Auth|PathSecret|ForwardedClientId|HealthCheck|Healthcheck|CORS|WebSocket|Alias|HttpServer|Tracing': ok.TestRedactedRequestURL,TestPathSecretAuth_NotOptedIn,TestAuthRegistry_ForwardedClientId*,TestAuthRegistry_SecondarySecretLocations,AcceptsSecretLocationandSupportstests for the secret and database strategies.srctypes updated (lib/not rebuilt; it is already behindsrcon this base);pnpm test: ok.AI assistance
🤖 Generated with Claude Code