fix(cli): authenticate endpoints whose spec security scheme was renamed by auth-schemes - #17366
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
fix(cli): authenticate endpoints whose spec security scheme was renamed by auth-schemes#17366devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…ed by auth-schemes The Rust CLI's routing auth provider matched the endpoint's declared security scheme names against the bindings registered from the IR. A generators.yml auth-schemes override renames the scheme (CustomAuth vs the spec's BearerAuth), so no requirement matched and requests went out unauthenticated. Also honor an OAuth scheme's tokenHeader/tokenPrefix when building WireMock auth matchers instead of always requiring Authorization: Bearer. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
… names Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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
Fixes the
cliseed shard that has been red onmainsince #17346 (oauth-client-credentials-openapi:with-wire-tests,wire_get/wire_list404 on a WireMock no-match). #17346 started emitting anAuthorizationmatcher foroauthschemes, which exposed two real bugs — the generated Rust CLI sends no auth header at all for that fixture, and the matcher ignores the scheme's configured token header.The CLI sent no credentials.
RoutingAuthProvidermaps the endpoint's declared security scheme names to registered bindings. The fixture'sgenerators.ymlrenames the scheme (auth-schemes: CustomAuth) while the baked spec's operations still reference the spec-declaredBearerAuth, so nothing matched and the request went out unauthenticated (only atracing::warn!). Now, when none of an endpoint's required schemes are bound at all, it defers to the defaultAnyAuthProviderinstead of dropping auth. A scheme that is bound but has no credentials keeps the existing unauthenticated path + friendly 401 message.The stub required the wrong header.
mock-utilshardcodedAuthorization: { matches: "Bearer .+" }for everyoauthscheme. The fixture pinstoken-header: token/token-prefix: "", so the correct matcher istoken: .+.getOAuthTokenPlacementnow readstokenHeader/tokenPrefix, and the basic+bearer-like collision case only applies when the OAuth scheme really writesAuthorization: Bearer.Verified end to end against a local HTTP mock that the built
plant-storebinary went from sending no auth header to sendingtoken: <access_token>after the token exchange.Changes Made
generators/cli/sdk/src/auth/compose.rs:RoutingAuthProviderfalls back to its default provider for requirements whose schemes are entirely unbound (apply+has_credentials_for).packages/commons/mock-utils/src/index.ts: OAuth auth matchers honor the scheme'stokenHeader/tokenPrefix.cliseed outputs (vendored SDK copy + the oauth fixture'swire-test-cases.json).generators/cli/changes/unreleased/.Testing
routing_unbound_requirement_falls_back_to_default(Rust) and an OAuth custom-token-header case ingenerators/cli/src/__test__/wireTests.test.ts.seed test --generator cli --fixture oauth-client-credentials-openapifails onmainand passes here; fullseed test --generator clireports only expected failures.Link to Devin session: https://app.devin.ai/sessions/840354f6bab64356b882ed2c0f20294f