Skip to content

Commit 3965ea8

Browse files
authored
Initial setup for credential resolution feature tracking (#4224)
## Motivation and Context Initial setup for tracking credential/identity resolution based features. ## Description The biggest change here is the addition of a new `aws-features` crate containing the `sdk_features` module that used to live in `aws-runtime`. This was done so that the `AwsSdkFeature` type could be referenced in the `aws-credential-types` crate without causing a circular dependency. Initially I was just going to pass along the types without downcasting, but they would have had to be downcast eventually, since in the `Credentials` typemap they are `Vec<AwsSdkFeature>` but to add them to a `Layer` we need to extract the individual `AwsSdkFeature`s from the `Vec`. This could either happen in `aws-credential-types` where `From<Credentials> for Identity` is implemented or in `aws-smithy-runtime` in the orchestrator where the `Identity` is resolved. Since these credentials types are AWS specific it seemed to make more sense to keep it in `aws/rust-runtime`. Other changes: * Add a typemap to `Credentials` (and manually implement the previously derived traits for it) to carry the feature information * Update the `From<Credentials> for Identity` implementation to extract the `AwsSdkFeatures` and pass them in a `Layer` to the `Identity`'s typemap. * Update `resolve_identity` in the orchestrator to extract the `FrozenLayer` from `Identity` and insert it in the `ConfigBag` so that the `UserAgentInterceptor` can extract it later. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> Added new tests around `Credentials` equality and the updated `From<Credentials> for Identity` implementation. **Note on failing semver test:** Failing because the `UnwindSafe` traits are no longer auto implemented for `Credentials` ``` --- failure auto_trait_impl_removed: auto trait no longer implemented --- Description: A public type has stopped implementing one or more auto traits. This can break downstream code that depends on the traits being implemented. ref: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/auto_trait_impl_removed.ron Failed in: type Credentials is no longer UnwindSafe, in /home/build/workspace/smithy-rs/aws-sdk/sdk/aws-credential-types/src/credentials_impl.rs:29 type Credentials is no longer RefUnwindSafe, in /home/build/workspace/smithy-rs/aws-sdk/sdk/aws-credential-types/src/credentials_impl.rs:29Cloning base ``` This is due to us adding a `HashMap<TypeId, TypeErasedBox>` to `Credentials`. We could likely wrap this in an `Arc<Mutex<>>` to keep it mutable and get back the unwind safety, but that doesn't feel like it justifies the added complexity. Open to debate on this one though. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 6649098 commit 3965ea8

File tree

15 files changed

+347
-57
lines changed

15 files changed

+347
-57
lines changed

aws/rust-runtime/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws/rust-runtime/aws-config/Cargo.lock

Lines changed: 16 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws/rust-runtime/aws-credential-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-credential-types"
3-
version = "1.2.4"
3+
version = "1.2.5"
44
authors = ["AWS Rust SDK Team <[email protected]>"]
55
description = "Types for AWS SDK credentials."
66
edition = "2021"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
use aws_smithy_types::config_bag::{Storable, StoreAppend};
7+
8+
/// IDs for the credential related features that may be used in the AWS SDK
9+
#[non_exhaustive]
10+
#[derive(Clone, Debug, Eq, PartialEq)]
11+
pub enum AwsCredentialFeature {
12+
/// An operation called using credentials resolved from code, cli parameters, session object, or client instance
13+
CredentialsCode,
14+
/// An operation called using credentials resolved from environment variables
15+
CredentialsEnvVars,
16+
/// An operation called using credentials resolved from environment variables for assuming a role with STS using a web identity token
17+
CredentialsEnvVarsStsWebIdToken,
18+
/// An operation called using credentials resolved from STS using assume role
19+
CredentialsStsAssumeRole,
20+
/// An operation called using credentials resolved from STS using assume role with SAML
21+
CredentialsStsAssumeRoleSaml,
22+
/// An operation called using credentials resolved from STS using assume role with web identity
23+
CredentialsStsAssumeRoleWebId,
24+
/// An operation called using credentials resolved from STS using a federation token
25+
CredentialsStsFederationToken,
26+
/// An operation called using credentials resolved from STS using a session token
27+
CredentialsStsSessionToken,
28+
/// An operation called using credentials resolved from a config file(s) profile with static credentials
29+
CredentialsProfile,
30+
/// An operation called using credentials resolved from a source profile in a config file(s) profile
31+
CredentialsProfileSourceProfile,
32+
/// An operation called using credentials resolved from a named provider in a config file(s) profile
33+
CredentialsProfileNamedProvider,
34+
/// An operation called using credentials resolved from configuration for assuming a role with STS using web identity token in a config file(s) profile
35+
CredentialsProfileStsWebIdToken,
36+
/// An operation called using credentials resolved from an SSO session in a config file(s) profile
37+
CredentialsProfileSso,
38+
/// An operation called using credentials resolved from an SSO session
39+
CredentialsSso,
40+
/// An operation called using credentials resolved from a process in a config file(s) profile
41+
CredentialsProfileProcess,
42+
/// An operation called using credentials resolved from a process
43+
CredentialsProcess,
44+
/// An operation called using credentials resolved from an HTTP endpoint
45+
CredentialsHttp,
46+
/// An operation called using credentials resolved from the instance metadata service (IMDS)
47+
CredentialsImds,
48+
}
49+
50+
impl Storable for AwsCredentialFeature {
51+
type Storer = StoreAppend<Self>;
52+
}

0 commit comments

Comments
 (0)