-
Notifications
You must be signed in to change notification settings - Fork 916
Add main auth scheme interfaces #3999
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
Add main auth scheme interfaces #3999
Conversation
/** | ||
* Interface for operating on an {@link IdentityProperty} value. | ||
*/ | ||
@FunctionalInterface | ||
interface IdentityPropertyConsumer<T> extends BiConsumer<IdentityProperty<T>, T> { | ||
} | ||
|
||
/** | ||
* Interface for operating on an {@link SignerProperty} value. | ||
*/ | ||
@FunctionalInterface | ||
interface SignerPropertyConsumer { | ||
<T> void accept(SignerProperty<T> propertyKey, T propertyValue); | ||
} |
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.
For the Consumers I did 2 different options. The Signer is as defined in the design doc. But using the BiConsumer seems to simplify the implementation - see DefaultHttpAuthOption. Do you think we should go the BiConsumer route?
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.
Yes. I can't think of a downside, and it's less verbose.
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.
Hmm, so building on command line didn't show any warnings, but IntelliJ shows me these warnings.
void forEachIdentityProperty(IdentityPropertyConsumer consumer);
-> Raw use of parameterized class 'IdentityPropertyConsumer'
and
identityProperties.forEach(consumer);
-> Unchecked assignment: 'software.amazon.awssdk.http.auth.spi.HttpAuthOption.IdentityPropertyConsumer' to 'java.util.function.BiConsumer<? super software.amazon.awssdk.identity.spi.IdentityProperty<?>,? super java.lang.Object>'
If I try to fix these, by adding type parameter <T>
to forEachIdentityProperty:
<T> void forEachIdentityProperty(IdentityPropertyConsumer<T> consumer);
I'm left with compiler error on
identityProperties.forEach(consumer);
-> 'forEach(java.util.function.BiConsumer<? super software.amazon.awssdk.identity.spi.IdentityProperty<?>,? super java.lang.Object>)' in 'java.util.Map' cannot be applied to '(software.amazon.awssdk.http.auth.spi.HttpAuthOption.IdentityPropertyConsumer<T>)'
Even if I go with the other approach, like in SignerPropertyConsumer, the forEachSignerProperty()
implementation as a cast with warning
SignerProperty<T> property = (SignerProperty<T>) p;
-> Unchecked cast: 'software.amazon.awssdk.http.auth.spi.SignerProperty<capture<?>>' to 'software.amazon.awssdk.http.auth.spi.SignerProperty<T>'
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.
With ^, I started initially to think the Raw use of parameterized class 'IdentityPropertyConsumer'
warning is ok to live with. But then realized that with this
interface IdentityPropertyConsumer<T> extends BiConsumer<IdentityProperty<T>, T> {
}
when instantiating the consumer would be tied to a specific type which may not be good. I feel I'm unsure what is better, until I try to write a real consumer.
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'm removing the <T>
from IdentityPropertyConsumer<T>
to not make the consumer tied to a type. This makes the interfaces match the original in the design doc.
for (SignerProperty<?> p : signerProperties.keySet()) { | ||
SignerProperty<T> property = (SignerProperty<T>) p; | ||
consumer.accept(property, this.signerProperty(property)); | ||
} |
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.
Maybe there is a better way to do this.
...h-spi/src/main/java/software/amazon/awssdk/http/auth/spi/internal/DefaultHttpAuthOption.java
Show resolved
Hide resolved
...h-spi/src/main/java/software/amazon/awssdk/http/auth/spi/internal/DefaultHttpAuthOption.java
Outdated
Show resolved
Hide resolved
core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/HttpAuthOption.java
Show resolved
Hide resolved
core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/HttpAuthOption.java
Show resolved
Hide resolved
core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/HttpAuthScheme.java
Outdated
Show resolved
Hide resolved
core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/HttpAuthOption.java
Show resolved
Hide resolved
...th-spi/src/main/java/software/amazon/awssdk/http/auth/spi/IdentityProviderConfiguration.java
Show resolved
Hide resolved
SonarCloud Quality Gate failed. |
Motivation and Context
As part of Smithy Reference Architecture, we are defining new Identity and Auth components. It introduces auth scheme and auth scheme resolution. This changes adds some of the auth scheme interfaces.
Modifications
Adding the main auth scheme interfaces here. Specific auth scheme interfaces like AwsV4HttpAuthScheme will be added in separate PR, after the corresponding signer interfaces are merged in #3997.
Note, I think the names may be subject to change as there are offline discussions happening on those. But I'd rather get these current names in and continue working on subsequent changes, and rename later, if needed.
Testing
./mvnw clean install -pl :http-auth-spi
successful locally.Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License