-
Notifications
You must be signed in to change notification settings - Fork 941
[SDK-3186] Support date/time custom claim validation #538
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
Conversation
@@ -517,7 +517,7 @@ public void shouldValidateCustomClaimOfTypeBoolean() { | |||
@Test | |||
public void shouldValidateCustomClaimOfTypeDate() { | |||
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoxNDc4ODkxNTIxfQ.mhioumeok8fghQEhTKF3QtQAksSvZ_9wIhJmgZLhJ6c"; | |||
Date date = new Date(1478891521000L); | |||
Date date = new Date(1478891521123L); |
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.
Changing the date time to include milliseconds causes this test to fail without the change to truncate milliseconds, demonstrating the issue with current custom Date
-based claim validation
Codecov failing because default implementation isn't covered. I'll look into adding a test for that (and other default implementations in that interface). |
Additional tests added for default method implementations in |
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.
Hey Jim, left a couple of subjective points on the PR. let me know what you think of it
52ccddd
to
451bf78
Compare
Changes
Adds a new verification method to verify a custom date/time claim:
Verification#withClaim(String name, Instant value)
Notes:
withClaim(String name, Date value)
method to avoid breaking changesDate
-based claim validation delegates to the newInstant
-based validation, allowing us to removeDate
-based validation codeDate
-based claim verification was arguably broken, or at least not intuitive. Because date claims are serialized as seconds since the epoch, any expectedDate
claim would need to have its milliseconds set to zero to be considered equal. This change fixes that by truncating the expected claim's value to seconds.References
Builds on #537