I have a JWT that Auth0 provided me when I authenticated via Lock in an Angular application.
I copied and pasted this token into a Ruby variable called token
.
Here's what I get on the Rails console when I try to decode the token:
> JWT.decode token, nil, false
=> [{"iss"=>"https://benfranklinlabs.auth0.com/", "sub"=>"auth0|58306f91c08814e01015f434", "aud"=>"8NWWMzcPNXEvxogqwRar18hJuYAvsrG0", "exp"=>1479766470, "iat"=>1479730470}, {"typ"=>"JWT", "alg"=>"HS256"}]
This is fine, except I thought the decoding process was supposed to require my Auth0 client's Client Secret. I'm using Knock with my Rails application which tries to decode the token like this:
JWT.decode token, decode_key, true, options.merge(verify_options)
And decode_key
is equal to this:
JWT.base64url_decode Rails.application.secrets.auth0_client_secret
And this attempt fails. I get the following error:
*** JWT::VerificationError Exception: Signature verification raised
I guess this makes sense. If I can decode the token just fine without using a key, then I imagine my token must not have been created with my Auth0 Client Secret factored in. I don't know this for a fact, though.
So my question is this: Knock seems to need to decode the token using my Auth0 Client Secret, but decoding the token using my Client Secret doesn't work. How can I get it to work?
Edit:
Here's my token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2JlbmZyYW5rbGlubGFicy5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NTgzMDZmOTFjMDg4MTRlMDEwMTVmNDM0IiwiYXVkIjoiajNKdHpjYnNpTUkyR0JkRnZGb3FFTjM4cUtTVmI2Q0UiLCJleHAiOjE0Nzk3NzE4ODMsImlhdCI6MTQ3OTczNTg4M30.MuUbdC7TLBcteKCry-sioeZVStI9TZ6TdsP5WG_6K08
Here's my Client ID: j3JtzcbsiMI2GBdFvFoqEN38qKSVb6CE
Here's my Client Secret: development_secret
true
inJWT.decode token, decode_key, true
meansverify
. If I set that argument tofalse
, it works whether I use a key or not. If I set that argument totrue
, it fails whether I use a key or not. – Jason Swett