OpenAPITools / OpenAPITools/openapi-generator
[BUG][RUST] AWS v4 Signing broken for requests with URL query parameters
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The recently added support in the rust client for AWS v4 signing is broken for requests with url parameters, as it ignores them completely.
openapi-generator version
6.0.0
OpenAPI declaration file content or url
modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
{{#withAWSV4Signature}}
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
let local_var_new_headers = match local_var_aws_v4_key.sign(
&local_var_uri_str, // <-- This line passes the url without any query parameters
"{{{httpMethod}}}",
Suggest a fix
I have got my project working with the following minimal change in an override template:
{{#withAWSV4Signature}}
if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
//=============================================================================
// Signing needs to include url query parameters, which will be missed by using
// just the path. Can be remediating by generating a full uri from a clone of
// the RequestBuilder, which will include any defined query parameters.
//
let uri_for_signing = local_var_req_builder
.try_clone()
.and_then(|rb| rb.build().ok().map(|r| r.url().to_string()))
.unwrap_or_else(|| local_var_uri_str.clone());
//=============================================================================
let local_var_new_headers = match local_var_aws_v4_key.sign(
&uri_for_signing,
"{{{httpMethod}}}",
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache and inspect the AWS v4 signing block, especially the URI passed to sign and the local_var_req_builder. Compare the current behavior with the suggested cloned-request URI. Done means generated Rust clients include URL query parameters in AWS v4 signatures while retaining the existing fallback behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, rust
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100