Skip to content

Migrate from v0.10 to v0.11 #3

Open
@hansonchar

Description

@hansonchar

I just realized this crate has a new release v0.11 but when I tried to compile my existing code based on v0.10.4, it failed with

error[E0432]: unresolved imports `scratchstack_aws_signature::sigv4_verify`, `scratchstack_aws_signature::Request`, `scratchstack_aws_signature::SigningKey`, `scratchstack_aws_signature::SigningKeyKind`
  --> src/xks_proxy/sigv4.rs:14:5
   |
14 |     sigv4_verify, Request as Sigv4Request, SigningKey, SigningKeyKind::KSecret,
   |     ^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^^^^^^^^ could not find `SigningKeyKind` in `scratchstack_aws_signature`
   |     |             |                        |
   |     |             |                        no `SigningKey` in the root
   |     |             |                        help: a similar name exists in the module: `KSigningKey`
   |     |             no `Request` in the root
   |     no `sigv4_verify` in the root

It seems the previous function sigv4_verify is now replaced by sigv4_validate_request which has an additional parameter of required_headers of type &SignedHeaderRequirements). Any suggestion on how to migrate to the latest API? This is what the existing code like:

...
use scratchstack_aws_signature::{
    sigv4_verify, Request as Sigv4Request, SigningKey, SigningKeyKind::KSecret,
};
...
    let signing_key = SigningKey {
        kind: KSecret,
        key: xks.sigv4_secret_access_key.as_str().as_bytes().to_vec(),
    };
    let allowed_mismatch = Some(Duration::minutes(5));
    if let Err(signature_error) = sigv4_verify(
        &sigv4_req,
        &signing_key,
        allowed_mismatch,
        SETTINGS.server.region.as_str(),
        SETTINGS.server.service.as_str(),
    ) {
        tracing::warn!("SigV4 failure: {signature_error}");
        return Err(AuthenticationFailedException.as_axum_error(signature_error.to_string()));
    }

Also, I don't seem to find a 0.11.x branch or tag. Is the main branch going to be used for 0.11.x?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions