feat: client-side auth - #21
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds client-side authentication support to the blocking reqwest client generator by lowering OpenAPI securitySchemes into the IR and emitting per-scheme credential fields + setters that are applied per operation based on effective security requirements.
Changes:
- Extend IR and lowering to carry document-level security schemes and per-operation effective security keys.
- Teach the reqwest client emitter to generate optional credential fields,
with_<scheme>setters, and per-request auth mutations; reject unsupported schemes (oauth2/oidc) via fixtures. - Add new snapshot + integration-style test coverage for auth credential placement and update README/coverage docs accordingly.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents client-side security scheme support and deferred oauth2/oidc. |
| crates/oapi-codegen/tests/generated/client_auth.rs | Adds generated snapshot exercising bearer/basic/apiKey auth emission. |
| crates/oapi-codegen/tests/generated_compiles.rs | Compiles new auth snapshot and adds a wire-level test for credential application. |
| crates/oapi-codegen/tests/fixtures/client_unsupported_oauth2.yaml | New fixture proving oauth2 is rejected by the client generator. |
| crates/oapi-codegen/tests/fixtures/client_auth.yaml | New fixture covering bearer/basic + apiKey header/query/cookie + security: []. |
| crates/oapi-codegen/tests/coverage.rs | Updates supported-surface tracking and fixture lists for client auth. |
| crates/oapi-codegen/src/lower/security.rs | New lowering module for security scheme catalog + effective requirements. |
| crates/oapi-codegen/src/lower/paths.rs | Populates Operation::security and prunes service-level schemes to “used”. |
| crates/oapi-codegen/src/lower/mod.rs | Exposes the new lower::security module. |
| crates/oapi-codegen/src/loader.rs | Adds accessors for global security and component securitySchemes. |
| crates/oapi-codegen/src/ir.rs | Extends IR with Service.security_schemes and security scheme/kind modeling. |
| crates/oapi-codegen/src/emit/reqwest.rs | Emits credential fields/setters and applies auth to requests; rejects unsupported schemes. |
Contributor
|
🎉 This PR is included in version 1.0.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Contributor
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
No description provided.