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

Inconsistent handling of payload claim data types #282

Closed
jamesstonehill opened this issue Sep 7, 2018 · 4 comments
Closed

Inconsistent handling of payload claim data types #282

jamesstonehill opened this issue Sep 7, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@jamesstonehill
Copy link
Contributor

When passing in a Time object as the value of the exp claim, if the key of the payload is a string it raises a JWT::InvalidPayload error. When using the symbol as the key, it does not raise the error.

When the exp claim key is a string

exp_payload = { 'exp' => Time.now }
token = JWT.encode exp_payload, 'asdf'
# => JWT::InvalidPayload: exp claim must be an integer

When the exp claim key is a symbol

exp_payload = { exp: Time.now }
token = JWT.encode exp_payload, 'asdf'
# => "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOiIyMDE4LTA5LTA3IDEzOjA3OjU0ICswMTAwIn0.9PxmdZFISuVXQQTDA6bw4vavK428o0R1WvcIZ5np6Lg"

Symbol and string keys in the payload should be handle in a consistent way.

@excpt excpt self-assigned this Sep 7, 2018
@excpt excpt added this to the Version 2.2.0 milestone Sep 7, 2018
@excpt
Copy link
Member

excpt commented Sep 7, 2018

Hi @jamesstonehill,

thanks for the detailed report. Can you specify your ruby-jwt version you're using?

@jamesstonehill
Copy link
Contributor Author

@excpt yeah, sorry I should have included that in the report. I'm using the latest release, 2.1.0.

@excpt
Copy link
Member

excpt commented Jan 21, 2019

@jamesstonehill can you check against the current master branch if #293 fixed this issue for you, please?

@jamesstonehill
Copy link
Contributor Author

@excpt yeah this is fixed in the current master.

@excpt excpt closed this as completed Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants