-
Notifications
You must be signed in to change notification settings - Fork 375
Closed
Description
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 integerWhen 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.