Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SsoTokenProvider #2917

Merged
merged 17 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-tls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: ../smithy-rs/tools/ci-scripts/configure-tls/configure-badssl
- name: Build SDK
working-directory: smithy-rs
run: ./gradlew :aws:sdk:assemble -Paws.services=+sts,+sso
run: ./gradlew :aws:sdk:assemble -Paws.services=+sts,+sso,+ssooidc
- name: Build trytls
shell: bash
working-directory: trytls
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
# included since aws-config depends on them. Transcribe Streaming and DynamoDB (paginators/waiters) were chosen
# below to stay small while still representing most features. Combined, they are about ~20MB at time of writing.
run: |
./gradlew -Paws.services=+sts,+sso,+transcribestreaming,+dynamodb :aws:sdk:assemble
./gradlew -Paws.services=+sts,+sso,+ssooidc,+transcribestreaming,+dynamodb :aws:sdk:assemble

# Copy the Server runtime crate(s) in
cp -r rust-runtime/aws-smithy-http-server rust-runtime/aws-smithy-http-server-python rust-runtime/aws-smithy-http-server-typescript aws/sdk/build/aws-sdk/sdk
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
# meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"}
# author = "rcoh"

[[aws-sdk-rust]]
message = "(Behavior Break!) The SSO credentials provider is no longer enabled by default in `aws-config`, and so SSO profile config will no longer work out of box. The `credentials-sso` feature in `aws-config` was removed from the default features, and renamed to `sso`. If you need credentials from SSO, then enable the `sso` feature in `aws-config`."
references = ["smithy-rs#2917"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "jdisanti"

[[aws-sdk-rust]]
message = "The `SsoCredentialsProvider` now supports token refresh and is compatible with the token cache file paths the latest AWS CLI uses."
references = ["smithy-rs#2917", "aws-sdk-rust#703", "aws-sdk-rust#699"]
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "jdisanti"

[[smithy-rs]]
message = "HTTP connector configuration has changed significantly. See the [upgrade guidance](https://github.com/awslabs/smithy-rs/discussions/3022) for details."
references = ["smithy-rs#3011"]
Expand Down Expand Up @@ -390,3 +402,9 @@ message = "[`PresignedRequest`](https://docs.rs/aws-sdk-s3/latest/aws_sdk_s3/pre
references = ["smithy-rs#3059"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "rcoh"

[[smithy-rs]]
message = "`RuntimeComponents` have been added as an argument to the `IdentityResolver::resolve_identity` trait function."
references = ["smithy-rs#2917"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client"}
author = "jdisanti"
11 changes: 7 additions & 4 deletions aws/rust-runtime/aws-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ client-hyper = ["aws-smithy-runtime/connector-hyper-0-14-x"]
rustls = ["aws-smithy-runtime/tls-rustls", "client-hyper"]
allow-compilation = [] # our tests use `cargo test --all-features` and native-tls breaks CI
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-runtime/rt-tokio", "tokio/rt"]
credentials-sso = ["dep:aws-sdk-sso", "dep:ring", "dep:hex", "dep:zeroize"]
sso = ["dep:aws-sdk-sso", "dep:aws-sdk-ssooidc", "dep:ring", "dep:hex", "dep:zeroize", "aws-smithy-runtime-api/http-auth"]

default = ["client-hyper", "rustls", "rt-tokio", "credentials-sso"]
default = ["client-hyper", "rustls", "rt-tokio"]

[dependencies]
aws-credential-types = { path = "../../sdk/build/aws-sdk/sdk/aws-credential-types" }
Expand Down Expand Up @@ -46,8 +46,13 @@ ring = { version = "0.16", optional = true }
hex = { version = "0.4.3", optional = true }
zeroize = { version = "1", optional = true }

# implementation detail of SSO OIDC `CreateToken` for SSO token providers
aws-sdk-ssooidc = { path = "../../sdk/build/aws-sdk/sdk/ssooidc", default-features = false, optional = true }

[dev-dependencies]
aws-credential-types = { path = "../../sdk/build/aws-sdk/sdk/aws-credential-types", features = ["test-util"] }
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client", "connector-hyper-0-14-x", "test-util"] }
aws-smithy-runtime-api = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["test-util"] }
futures-util = { version = "0.3.16", default-features = false }
tracing-test = "0.2.1"
tracing-subscriber = { version = "0.3.16", features = ["fmt", "json"] }
Expand All @@ -61,8 +66,6 @@ arbitrary = "1.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

aws-credential-types = { path = "../../sdk/build/aws-sdk/sdk/aws-credential-types", features = ["test-util"] }

# used for a usage example
hyper-rustls = { version = "0.24", features = ["webpki-tokio", "http2", "http1"] }
aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async", features = ["rt-tokio", "test-util"] }
Expand Down
1 change: 1 addition & 0 deletions aws/rust-runtime/aws-config/external-types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ allowed_external_types = [
"aws_smithy_runtime_api::client::dns::SharedDnsResolver",
"aws_smithy_runtime_api::client::http::HttpClient",
"aws_smithy_runtime_api::client::http::SharedHttpClient",
"aws_smithy_runtime_api::client::identity::ResolveIdentity",
"aws_smithy_types::retry",
"aws_smithy_types::retry::*",
"aws_smithy_types::timeout",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ mod test {
make_test!(ecs_credentials);
make_test!(ecs_credentials_invalid_profile);

#[cfg(not(feature = "credentials-sso"))]
make_test!(sso_assume_role #[should_panic(expected = "This behavior requires following cargo feature(s) enabled: credentials-sso")]);
#[cfg(not(feature = "credentials-sso"))]
make_test!(sso_no_token_file #[should_panic(expected = "This behavior requires following cargo feature(s) enabled: credentials-sso")]);
#[cfg(not(feature = "sso"))]
make_test!(sso_assume_role #[should_panic(expected = "This behavior requires following cargo feature(s) enabled: sso")]);
#[cfg(not(feature = "sso"))]
make_test!(sso_no_token_file #[should_panic(expected = "This behavior requires following cargo feature(s) enabled: sso")]);

#[cfg(feature = "credentials-sso")]
#[cfg(feature = "sso")]
make_test!(sso_assume_role);

#[cfg(feature = "credentials-sso")]
#[cfg(feature = "sso")]
make_test!(sso_no_token_file);

#[cfg(feature = "credentials-sso")]
Expand Down
6 changes: 5 additions & 1 deletion aws/rust-runtime/aws-config/src/imds/client/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ fn parse_token_response(response: &HttpResponse, now: SystemTime) -> Result<Toke
}

impl ResolveIdentity for TokenResolver {
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a> {
fn resolve_identity<'a>(
&'a self,
_components: &'a RuntimeComponents,
_config_bag: &'a ConfigBag,
) -> IdentityFuture<'a> {
IdentityFuture::new(async {
let preloaded_token = self
.inner
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub mod meta;
pub mod profile;
pub mod provider_config;
pub mod retry;
#[cfg(feature = "credentials-sso")]
#[cfg(feature = "sso")]
pub mod sso;
pub(crate) mod standard_property;
pub mod sts;
Expand Down
12 changes: 7 additions & 5 deletions aws/rust-runtime/aws-config/src/profile/credentials/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use super::repr::{self, BaseProvider};
use crate::credential_process::CredentialProcessProvider;
use crate::profile::credentials::ProfileFileError;
use crate::provider_config::ProviderConfig;
#[cfg(feature = "credentials-sso")]
use crate::sso::{SsoCredentialsProvider, SsoProviderConfig};
use crate::sts;
use crate::web_identity_token::{StaticConfiguration, WebIdentityTokenCredentialsProvider};
use aws_credential_types::provider::{
Expand Down Expand Up @@ -119,21 +117,25 @@ impl ProviderChain {
sso_role_name,
sso_start_url,
} => {
#[cfg(feature = "credentials-sso")]
#[cfg(feature = "sso")]
{
use crate::sso::{credentials::SsoProviderConfig, SsoCredentialsProvider};
use aws_types::region::Region;

let sso_config = SsoProviderConfig {
account_id: sso_account_id.to_string(),
role_name: sso_role_name.to_string(),
start_url: sso_start_url.to_string(),
region: Region::new(sso_region.to_string()),
// TODO(https://github.com/awslabs/aws-sdk-rust/issues/703): Implement sso_session_name profile property
session_name: None,
};
Arc::new(SsoCredentialsProvider::new(provider_config, sso_config))
}
#[cfg(not(feature = "credentials-sso"))]
#[cfg(not(feature = "sso"))]
{
Err(ProfileFileError::FeatureNotEnabled {
feature: "credentials-sso".into(),
feature: "sso".into(),
})?
}
}
Expand Down
Loading