Phase 7c: auth hooks (@httpBearerAuth / @httpApiKeyAuth) + generated paginators - #17
Merged
Merged
Conversation
…ginators - ClientConfig gains bearer_token and api_key credential providers (called per request, so rotation just works). Generated clients wire them per the service's auth traits: @httpBearerAuth sends "authorization: Bearer <token>"; @httpApiKeyAuth sends the key where the model binds it — named header with the trait's optional scheme prefix, or query parameter (percent-encoded). Null providers leave requests anonymous. Fixtures cover all three shapes: weather (bearer), cafe (header api key), roundtrip REST (query api key). - Server-side guards ship as middleware: RequireBearerAuth (RFC 6750 scheme matched case-insensitively) and RequireApiKeyHeader (optional scheme prefix), both 401 on failure. - @paginated operations with top-level string tokens get a generated paginator: client.Paginate<Op>(input) returns <Op>Paginator whose Next() yields one page at a time, feeds the output token back into the input, and returns nullopt once the token is absent or empty (never loops on an echoing server; errors stop pagination). The paginator owns a copy of the client and input. Nested token paths and non-string tokens are skipped. - Weather e2e: bearer token flows from config through the generated client into RequireBearerAuth middleware; the paginator walks both pages and stays exhausted. Cafe wire test pins the x-api-key header. - docs: production-guide auth + pagination sections; runtime overview, README status updates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WjaNFwBZxoHdqagvq8ycQf
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.
Third Phase 7 hardening slice: credential wiring from the model's auth traits, matching server-side guards, and generated paginators from
@paginated.Client auth (
//runtime:client+ codegen)ClientConfiggainsbearer_tokenandapi_keyproviders (std::function<std::string()>, called per request so credential rotation just works; null providers leave requests anonymous).@httpBearerAuthsendsauthorization: Bearer <token>;@httpApiKeyAuthsends the key where the model binds it — named header with the trait's optional scheme prefix, or percent-encoded query parameter.@httpBearerAuth), cafe (@httpApiKeyAuthheader), roundtrip REST (@httpApiKeyAuthquery).Server auth middleware (
//runtime:server)RequireBearerAuth(validator)(RFC 6750 scheme matched case-insensitively) andRequireApiKeyHeader(name, scheme, validator), both rejecting with 401 before the router runs — built on the Phase 7b middleware seam. Vendor-specific signing schemes (SigV4 etc.) stay out of scope per the vendor-neutrality rule; the interceptor seam is the extension point.Generated paginators
@paginatedoperations with top-level string tokens get a<Op>Paginator:client.Paginate<Op>(input)→Next()yields one page at a time, feeds the output token back into the input, and returnsstd::nulloptonce the token is absent or empty (defensive: never loops on a server echoing empty tokens; a failed call stops pagination and returns the error). The paginator owns a copy of the client and input, so it outlives both. Nested output-token paths and non-string tokens are skipped.Tests
config.bearer_tokenthrough the generated client intoRequireBearerAuthon the generated server (anonymous call rejected, authorized call round-trips); the paginator walks both pages, reports exhaustion, and stays exhausted.x-api-keyheader on captured requests (and its absence without a provider).Docs
Production guide gains Auth and Pagination sections with worked examples; runtime overview and README updated.
Validation
bazel test //...— 44/44 green locally, plus ASan+UBSan (Beast targets CI-verified as usual)🤖 Generated with Claude Code
https://claude.ai/code/session_01WjaNFwBZxoHdqagvq8ycQf
Generated by Claude Code