-
Notifications
You must be signed in to change notification settings - Fork 124
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
Preferred way to check if a Signed GlobalID is expired? #141
Comments
I'd be interested as well - we want to know if & when a globalid expired to show users an info like "this link expired on XXX". Currently we do this manually using |
I'd take #expired? 👍 |
If we want to implement this it need to be in the https://github.com/rails/rails/blob/main/activesupport/lib/active_support/message_verifier.rb The current code here is going to be removed to verify the message is legacy and will be removed. See #107 |
PR to add to Rails: rails/rails#48820 Once that's merged I can make a PR here to add |
The documentation for Signed Global IDs shows that they can have an expiry date. I know that if the SGID is expired, then trying to use it to locate a record returns
nil
. But returningnil
could also mean that the record indicated by the SGID no longer exists.Is there a way to specifically tell that the SGID is expired? I see in the code, an
ExpiredMessage
exception is actually raised, but it is immediately caught and turned intonil
.globalid/lib/global_id/signed_global_id.rb
Lines 32 to 40 in 3ddb0f8
I could use the
SignedGlobalID#verifier
to decode the message and then get theexpired_at
attribute out of the Hash. That seems hacky to me, so I was wondering if there was another way to check for expiration?Would a PR to add an
expired?
method toSignedGlobalID
be welcome? I'd be happy to work on that.Thanks!
The text was updated successfully, but these errors were encountered: