-
Notifications
You must be signed in to change notification settings - Fork 910
Adding functionality to config preferred authschemeProvider #6083
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
base: master
Are you sure you want to change the base?
Conversation
362e5f3
to
f18fcc2
Compare
...st/resources/software/amazon/awssdk/codegen/poet/auth/scheme/query-auth-scheme-provider.java
Show resolved
Hide resolved
return new QueryAuthSchemeProviderBuilder(); | ||
} | ||
|
||
interface Builder { |
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.
Can we make it extend CopyableBuilder? https://github.com/aws/aws-sdk-java-v2/blob/master/docs/design/ClientConfiguration.md
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 updates on this?
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.
Sorry I missed this comment earlier - I don't think we can do that without it being a breaking change. This would require adding the toBuilder method on the AuthSchemeProvider interface (and having it extend ToCopyableBuilder). This would be a breaking change to existing customer defined AuthSchemeProviders.
The original design suggested overloading the existing defaultProvider()
method with a defaultProvider(List authSchemePreference) method instead of using a builder. Would that be preferable?
Will discuss offline in surface api review meeting.
...aws-core/src/main/java/software/amazon/awssdk/awscore/auth/AuthSchemePreferenceProvider.java
Outdated
Show resolved
Hide resolved
...aws-core/src/main/java/software/amazon/awssdk/awscore/auth/AuthSchemePreferenceProvider.java
Outdated
Show resolved
Hide resolved
...rc/test/java/software/amazon/awssdk/services/multiauth/AuthSchemePreferenceProviderTest.java
Outdated
Show resolved
Hide resolved
...aws-core/src/main/java/software/amazon/awssdk/awscore/auth/AuthSchemePreferenceProvider.java
Outdated
Show resolved
Hide resolved
...in/java/software/amazon/awssdk/codegen/poet/auth/scheme/PreferredAuthSchemeProviderSpec.java
Show resolved
Hide resolved
...in/java/software/amazon/awssdk/codegen/poet/auth/scheme/PreferredAuthSchemeProviderSpec.java
Show resolved
Hide resolved
...rc/test/java/software/amazon/awssdk/services/multiauth/AuthSchemePreferenceProviderTest.java
Outdated
Show resolved
Hide resolved
...st/resources/software/amazon/awssdk/codegen/poet/auth/scheme/query-auth-scheme-provider.java
Show resolved
Hide resolved
...st/resources/software/amazon/awssdk/codegen/poet/auth/scheme/query-auth-scheme-provider.java
Show resolved
Hide resolved
.../amazon/awssdk/codegen/poet/auth/scheme/query-endpoint-auth-params-auth-scheme-provider.java
Show resolved
Hide resolved
...aws-core/src/main/java/software/amazon/awssdk/awscore/auth/AuthSchemePreferenceProvider.java
Outdated
Show resolved
Hide resolved
...aws-core/src/main/java/software/amazon/awssdk/awscore/auth/AuthSchemePreferenceProvider.java
Outdated
Show resolved
Hide resolved
...aws-core/src/main/java/software/amazon/awssdk/awscore/auth/AuthSchemePreferenceProvider.java
Outdated
Show resolved
Hide resolved
...aws-core/src/main/java/software/amazon/awssdk/awscore/auth/AuthSchemePreferenceProvider.java
Outdated
Show resolved
Hide resolved
...in/java/software/amazon/awssdk/codegen/poet/auth/scheme/PreferredAuthSchemeProviderSpec.java
Show resolved
Hide resolved
...ces/software/amazon/awssdk/codegen/poet/auth/scheme/test-preferred-auth-scheme-provider.java
Outdated
Show resolved
Hide resolved
This reverts commit 141b9d6.
|
return new QueryAuthSchemeProviderBuilder(); | ||
} | ||
|
||
interface Builder { |
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 updates on this?
} | ||
|
||
@SdkInternalApi | ||
final class QueryAuthSchemeProviderBuilder implements Builder { |
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 updates on this?
List<AuthSchemeOption> authSchemes = new ArrayList<>(); | ||
authSchemePreference.forEach(preferredSchemeId -> { | ||
candidateAuthSchemes | ||
.stream() | ||
.filter(candidate -> { | ||
String candidateSchemeName = candidate.schemeId().contains("#") ? candidate.schemeId().split("#")[1] | ||
: candidate.schemeId(); | ||
return candidateSchemeName.equals(preferredSchemeId); | ||
}).findFirst().ifPresent(authSchemes::add); | ||
}); | ||
candidateAuthSchemes.forEach(candidate -> { | ||
if (!authSchemes.contains(candidate)) { | ||
authSchemes.add(candidate); | ||
} | ||
}); |
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 doesn't seem to be very efficient O(n * m)
. Is that a concern?
Dismissing to unblock the change since I'm OOTO.
Motivation and Context
Previously, when multiple auth schemes were available for an operation, the SDK would choose the first one defined in the service model. This PR implements the auth scheme preference configuration that allows users to specify their preferred authentication schemes in order of preference when multiple auth schemes are supported.
Example usage:
Modifications
[Modified] client builders to read and apply auth scheme preferences
[Modified] the auth scheme resolution logic to respect user preferences while maintaining backward compatibility
[Added]
AuthSchemePreferenceProvider
class to resolve auth scheme preferences from various sources:aws.authSchemePreference
)AWS_AUTH_SCHEME_PREFERENCE
)auth_scheme_preference
)[Added] code generation support through PreferredAuthSchemeProviderSpec to generate service-specific auth scheme providers
Testing
AuthSchemePreferenceProviderTest
verifies proper parsing of auth scheme preferences from different formats (spaces, tabs, etc.)PreferredAuthSchemeProviderTest
to test the reordering of auth schemes according to preferencescomprehensive test cases for preference resolution from multiple sources, verifying proper precedence:
Stubbed functional test with mock services to verify the selected auth scheme matches the expected preference in actual requests