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

Implement Claim::set_expires_in #107

Merged
merged 1 commit into from
Dec 12, 2023
Merged

Implement Claim::set_expires_in #107

merged 1 commit into from
Dec 12, 2023

Conversation

franklx
Copy link
Contributor

@franklx franklx commented Dec 9, 2023

Implemented new function Claim::set_expires_in(&mut self, duration: &core::time::Duration) -> Result<(), Error> useful for refreshing claims on expired tokens.
Used it even for new and new_expires_in constructors.

@brycx
Copy link
Owner

brycx commented Dec 11, 2023

Hi, sorry for the wait. I'll try to get this reviewed within the next few days.

Copy link
Owner

@brycx brycx left a comment

Choose a reason for hiding this comment

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

Thank you for working on this! The code looks good and I'm ready to approve this, but I'd like to understand the use-case a bit more, before merging.

When would you want to change an expiry for an already signed set of Claims? The only time where you'd possibly attempt to modify a token, as far as I can imagine, is a public one. Claims are signed when used with the tokens, so just changing them there would invalidate the signature.

Do you have an application where you store plaintext Claims in-memory, that can't be re-constructed easily, but are re-used across expiring/different tokens?

@franklx
Copy link
Contributor Author

franklx commented Dec 11, 2023

I'm working on an actix-web paseto-based authentication middleware: franklx/actix-paseto-auth-middleware.

When the access_token is expired is convenient using it as base for creating a new one based on refresh_token (like original implementation based on jwt does).

If you are interested here is where the token is created by calling a "polymorphic" function defined here where the set_expires_in is called.

@brycx
Copy link
Owner

brycx commented Dec 12, 2023

@franklx Thanks for clarifying. Off the top of my head, this seems fine to me. I'll get this merged and issue a new release.

Out in 0.6.8.

@brycx brycx merged commit 8dce01a into brycx:master Dec 12, 2023
8 checks passed
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.

None yet

2 participants