-
Notifications
You must be signed in to change notification settings - Fork 227
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
feat: implements AWS signature version 4 for signing requests #476
Conversation
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.
See https://twitter.com/elharo/status/976612920565125124 about constants
I need to take a closer look at the exceptions thrown here.
oauth2_http/java/com/google/auth/oauth2/AwsRequestSignature.java
Outdated
Show resolved
Hide resolved
oauth2_http/java/com/google/auth/oauth2/AwsRequestSignature.java
Outdated
Show resolved
Hide resolved
oauth2_http/java/com/google/auth/oauth2/AwsRequestSignature.java
Outdated
Show resolved
Hide resolved
oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java
Outdated
Show resolved
Hide resolved
oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java
Outdated
Show resolved
Hide resolved
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.
Don't use runtime exceptions for any probles that comes from outside the program such as a malformed HTTP header
oauth2_http/java/com/google/auth/oauth2/AwsRequestSignature.java
Outdated
Show resolved
Hide resolved
…Digest, and misc changes
import static com.google.api.client.util.Preconditions.checkNotNull; | ||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
import com.google.api.client.util.Clock; |
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.
Anyone know why we use these classes instead of the better maintained versions in Java?
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 think @elharo is suggesting keeping a Date
instance rather than a collection of pre-formatted string values. Then formatting them on the way out when necessary.
private AwsDates(String originalDate, String amzDate, String formattedDate) { | ||
this.originalDate = checkNotNull(originalDate); | ||
this.amzDate = checkNotNull(amzDate); | ||
this.formattedDate = checkNotNull(formattedDate); |
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.
It looks like this value is always computed from the amzDate
argument which puts burden on the caller to always do the substring(0,8)
to take the YYYMMDD part from amzDate
. Intentional for some use-case?
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, I think having a Date instance would then burden the callers to convert the input (always a String) to a date, only to be converted back anyway.
I cleaned it up a little - you're right, there's no need to hold onto the formattedDate since it is always derived from the amzDate.
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 classes are all package private and we can clean up in the final PR if necessary.
Review comments resolved, we can revisit in the final PR.
https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html