Repository navigation
feat(security): an oauth2 scheme is a bearer at runtime - #3
Merged
Merged
Conversation
An OAuth 2.0 access token is sent as `Authorization: Bearer <token>` (RFC 6750), so at runtime an `oauth2` security scheme is a bearer credential. Both converters mapped it to `other`, which the Go and Java SDKs and both CLI generators treat as "send nothing". - openapi2opensdk: `oauth2` -> `kind: "bearer"`, `scheme: "bearer"`, plus `flows` (the flow types, document order, `x-*` keys skipped) and `scopes` (the scope catalogue merged across flows, first description wins). Both are optional and appended last, so every existing IR keeps its bytes; they are declared on `SdkSecurity` in the IR schema. - openapi2opencli: `oauth2` -> `kind: "bearer"`, `scheme: "bearer"`. - Generated SDKs and CLIs for an oauth2 document are byte-identical to the http/bearer ones (same env var, same header), pinned for all nine targets in the CLI behavior suite. - `opensdk diff` no longer reports an http/bearer -> oauth2 document as `security-changed`; an unmapped scheme still is. - README: an Authentication section; CHANGELOG: Unreleased entry.
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.
An OpenAPI security scheme of
type: oauth2is, at runtime, a bearer token (RFC 6750: the access token travels asAuthorization: Bearer <token>), so both converters now map it to thebearerkind:openapi2opensdk:oauth2→kind: "bearer",scheme: "bearer", the scheme's name and env var kept; two optional IR fields record the flow types (flows) and the merged scope catalogue (scopes), left out when empty — other schemes serialize exactly as before (no golden moved). The IR schema declares both.openapi2opencli:oauth2→kind: "bearer".kind, so the output for an oauth2 document is byte-identical to the same document with anhttp/bearerscheme (a behaviour test generates all nine targets both ways and compares). For the Go and Java SDKs and both CLI generators this is also a fix: they sent no credential at all for an unrecognised scheme.opensdk diff: a document-level move fromhttp/bearertooauth2is not asecurity-changed(tested;openIdConnectstill is). A per-operation move to a scoped requirement is still reported, by design — a client lacking the scope breaks.Gates:
cargo fmt --check,clippy --workspace --all-targets -D warnings,cargo test --workspace527 passed,scripts/check-standalone.shOK. README gains an Authentication section; CHANGELOG has the Unreleased entry.