-
Notifications
You must be signed in to change notification settings - Fork 190
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
Replace credentials cache with identity cache #3077
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic! With this, have we already addressed the known credentials_cache/credentials_provider duality issue?
@@ -827,35 +834,5 @@ mod loader { | |||
let num_requests = num_requests.load(Ordering::Relaxed); | |||
assert!(num_requests > 0, "{}", num_requests); | |||
} | |||
|
|||
#[tokio::test] | |||
async fn time_source_is_passed() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test no longer applicable or did it not add much value in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time source and sleep aren't stored in the cache anymore, but rather, are passed in on every cache request. So there's nothing to test here.
/// | ||
/// This trait can be used to validate that certain required components or config values | ||
/// are available, and provide an error with helpful instructions if they are not. | ||
pub trait ValidateConfig: fmt::Debug + Send + Sync { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Love the idea of having a centralized place for validating config 🎉
Yes. They're completely isolated from each other in config now. |
let token = match preloaded_token { | ||
Some(token) => Ok(token), | ||
Some(token) => { | ||
tracing::debug!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want this at trace
@@ -102,6 +102,12 @@ pub use aws_types::{ | |||
/// Load default sources for all configuration with override support | |||
pub use loader::ConfigLoader; | |||
|
|||
/// Types for configuring identity caching. | |||
pub mod identity { | |||
pub use aws_smithy_runtime::client::identity::IdentityCache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any issue with the re-export aws_smithy_runtime here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it belongs in aws-smithy-runtime-api since that crate is intended for library authors, and concrete built-in identity cache implementations aren't needed for that. So that leaves us with two options: 1. put them in aws-smithy-runtime, or 2. create a new crate for them.
I opted to go for 1, but that probably means we have to make aws-smithy-runtime a stable crate.
/// Override the credentials cache used to build [`SdkConfig`](aws_types::SdkConfig). | ||
/// Override the identity cache used to build [`SdkConfig`](aws_types::SdkConfig). | ||
/// | ||
/// The identity cache caches credentials and SSO tokens. By default, a lazy cache is used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWS credentials
?
/// // change the load timeout to 10 seconds | ||
/// .load_timeout(Duration::from_secs(10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may want to note that there may be other timeouts that could trigger
/// .load() | ||
/// .await; | ||
/// # } | ||
/// ``` | ||
pub fn credentials_cache(mut self, credentials_cache: CredentialsCache) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deprecate credentials_cache
and leave a breadcrumb?
@@ -44,6 +44,7 @@ pub struct InterceptorError { | |||
|
|||
impl InterceptorError { | |||
interceptor_error_fn!(read_before_execution => ReadBeforeExecution (with source)); | |||
interceptor_error_fn!(read_after_configuration => ReadAfterConfiguration (with source)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you still mean to add this error? I could be searching badly but I don't see it used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I meant to remove this. Good catch!
@@ -187,6 +187,8 @@ impl AuthScheme for SharedAuthScheme { | |||
} | |||
} | |||
|
|||
impl ValidateConfig for SharedAuthScheme {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these be delegating to their inner members? (either now or eventially)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, yes. I figure we'll add them as they're needed.
|
||
#[derive(Clone)] | ||
enum ValidatorInner { | ||
BaseConfigStaticFn(fn(&RuntimeComponentsBuilder, &ConfigBag) -> Result<(), BoxError>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it's worth having the two variants—I think you could turn one into the other during construction?
doesn't really matter anyway though—it's private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just avoiding unnecessary allocation.
/// Creates a base client validator from a function. | ||
pub fn base_client_config_fn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example may be helpful
tracing::trace!(concat!( | ||
"running `", | ||
stringify!($interceptor), | ||
"` interceptors" | ||
)); | ||
let mut result: Result<(), (&str, BoxError)> = Ok(()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we logging here, may be nice to log how many too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't actually know the count until we've looped over them since we only have an iterator here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great!
A new generated diff is ready to view.
A new doc preview is ready to view. |
…only at operation level (#3156) ## Motivation and Context Fixes awslabs/aws-sdk-rust#901 ## Description This PR is a rework of #3021 whose fix was inadvertently discarded during #3077. The way we fix the issue is slightly different. In this PR, we add an identity resolver to runtime components within `set_credentials_provider`, instead of using `ServiceConfig.OperationConfigOverride`. ## Testing Added a Kotlin integration test to `CredentialProviderConfigTest.kt` based on the customer reported issue. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
…only at operation level (#3156) Fixes awslabs/aws-sdk-rust#901 This PR is a rework of #3021 whose fix was inadvertently discarded during #3077. The way we fix the issue is slightly different. In this PR, we add an identity resolver to runtime components within `set_credentials_provider`, instead of using `ServiceConfig.OperationConfigOverride`. Added a Kotlin integration test to `CredentialProviderConfigTest.kt` based on the customer reported issue. <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
…only at operation level (#3156) Fixes awslabs/aws-sdk-rust#901 This PR is a rework of #3021 whose fix was inadvertently discarded during #3077. The way we fix the issue is slightly different. In this PR, we add an identity resolver to runtime components within `set_credentials_provider`, instead of using `ServiceConfig.OperationConfigOverride`. Added a Kotlin integration test to `CredentialProviderConfigTest.kt` based on the customer reported issue. <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
This PR replaces the credentials cache with the new identity cache, and adds config validation via the
SharedConfigValidator
runtime component andValidateConfig
trait.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.