Skip to content
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

fix: durations #4

Merged
merged 2 commits into from
Aug 21, 2023
Merged

fix: durations #4

merged 2 commits into from
Aug 21, 2023

Conversation

Tomsons
Copy link
Contributor

@Tomsons Tomsons commented Aug 17, 2023

The current claim deserialization uses a base64 decoder to decode the jwt string part. By default, the base64 library decodes timestamps aka u64 into f64 which causes Errors when deserializing a token that iat, exp etc with timestamps.

What has been done:

  • Introduced serde_with library
  • Deserialized directly into Duration
  • Added extra unit test to check

@Tomsons Tomsons force-pushed the main branch 2 times, most recently from 288e7fc to 1224a89 Compare August 17, 2023 15:46
@blckngm
Copy link
Owner

blckngm commented Aug 18, 2023

Thanks for letting me know that these timestamps can be float. I'll leave some comments.

@@ -65,15 +68,16 @@ impl<T> Default for OneOrMany<T> {
}

/// JWT Claims.
#[serde_as]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are using serde_with, we might as well use skip_serializing_none.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@Tomsons Tomsons requested a review from blckngm August 18, 2023 07:18
@blckngm blckngm merged commit 5681f56 into blckngm:main Aug 21, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants