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

Decoding jwt is missing "jti" #3

Closed
rlam3 opened this issue Sep 19, 2016 · 6 comments
Closed

Decoding jwt is missing "jti" #3

rlam3 opened this issue Sep 19, 2016 · 6 comments

Comments

@rlam3
Copy link
Contributor

rlam3 commented Sep 19, 2016

I'm get the following error when using the provided token back to the refresh link.
The refresh_token wasn't used in the process?

Header:
Authorization: Bearer

{
  "msg": "Missing or invalid claim: jti"
}
@vimalloc
Copy link
Owner

It seems to work for me. Did you make any changes which would cause flask reloader to kick in after generating your access/refresh tokens? In that example app, the blacklist is enabled, but we are storing the token data in memory, so if the flask app restarts, your token is still valid, but it cannot find it in the blacklist store (this is why redis/memcached/sqlalchemy should be used in prod).

curl -H "Content-Type: application/json" -X POST -d '{"username":"test1","password":"abc123"}' http://localhost:5000/auth/login
{                     
  "access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzQzMTA0MjksImZyZXNoIjp0cnVlLCJpYXQiOjE0NzQzMDY4MjksImp0aSI6IjNiNzgzOGI4LTg3MWEtNGRiMi1iOWI1LTkyOTVhZTJlZTAwMiIsImlkZW50aXR5IjoidGVzdDEiLCJ0eXBlIjoiYWNjZXNzIiwidXNlcl9jbGFpbXMiOnsidHlwZSI6InRlY2huaWNpYW4iLCJpcCI6IjEyNy4wLjAuMSJ9LCJuYmYiOjE0NzQzMDY4Mjl9.KKyMvgei_1d60q6Dw_r-fT0co004M5PxrZuhmbfre5VQKjqghnMvf7kTECyHQQHh8uV7O5AURo1ImJWmHS1oqw", 
  "refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzQ5MTE2MjksImlhdCI6MTQ3NDMwNjgyOSwianRpIjoiZTJjM2Q4ODAtMDIxYy00NDE5LTg4OWItNGM1ZjY2ODljMjU2IiwiaWRlbnRpdHkiOiJ0ZXN0MSIsInR5cGUiOiJyZWZyZXNoIiwibmJmIjoxNDc0MzA2ODI5fQ.5KWz0IR28Z__bVnQZ6WhD1BQoSBYUPDaSfgsvky3eURZDkLqbdRRaTMUOer5p2LIRb-2bI7NSXzvn7R83WkZPw"
}

export ACCESS="eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzQzMTA0MjksImZyZXNoIjp0cnVlLCJpYXQiOjE0NzQzMDY4MjksImp0aSI6IjNiNzgzOGI4LTg3MWEtNGRiMi1iOWI1LTkyOTVhZTJlZTAwMiIsImlkZW50aXR5IjoidGVzdDEiLCJ0eXBlIjoiYWNjZXNzIiwidXNlcl9jbGFpbXMiOnsidHlwZSI6InRlY2huaWNpYW4iLCJpcCI6IjEyNy4wLjAuMSJ9LCJuYmYiOjE0NzQzMDY4Mjl9.KKyMvgei_1d60q6Dw_r-fT0co004M5PxrZuhmbfre5VQKjqghnMvf7kTECyHQQHh8uV7O5AURo1ImJWmHS1oqw" 
export REFRESH="eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzQ5MTE2MjksImlhdCI6MTQ3NDMwNjgyOSwianRpIjoiZTJjM2Q4ODAtMDIxYy00NDE5LTg4OWItNGM1ZjY2ODljMjU2IiwiaWRlbnRpdHkiOiJ0ZXN0MSIsInR5cGUiOiJyZWZyZXNoIiwibmJmIjoxNDc0MzA2ODI5fQ.5KWz0IR28Z__bVnQZ6WhD1BQoSBYUPDaSfgsvky3eURZDkLqbdRRaTMUOer5p2LIRb-2bI7NSXzvn7R83WkZPw"

curl -H "Authorization: Bearer $REFRESH" -X POST http://localhost:5000/auth/refresh 
{                                                                                    
  "access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzQzMTA0NTcsImZyZXNoIjpmYWxzZSwiaWF0IjoxNDc0MzA2ODU3LCJqdGkiOiIzMjZiYjkwOC02NmFjLTRiYTUtODJlZC04Y2RiNzNmMjZkZmIiLCJpZGVudGl0eSI6InRlc3QxIiwidHlwZSI6ImFjY2VzcyIsInVzZXJfY2xhaW1zIjp7InR5cGUiOiJ0ZWNobmljaWFuIiwiaXAiOiIxMjcuMC4wLjEifSwibmJmIjoxNDc0MzA2ODU3fQ.8jglk7h_9JEWmengK1WYJ7L1d5XbGla1e9K4kSkUHpRnW7HCLUwuka_TiKyRYtUmQbLYbAWK_sbGwF-n9iaSiQ"
}

@vimalloc
Copy link
Owner

Oh, you mean if no token was supplied to the call. Yeah, that is the default handler for that error case. You can change it with the invalid_token_loader decorator. See this file https://github.com/vimalloc/flask-jwt-extended/blob/master/flask_jwt_extended/jwt_manager.py

@vimalloc
Copy link
Owner

That said, I think that can be done better. I'll look at it more today.

@vimalloc
Copy link
Owner

Actually, now that I'm actually sitting down and looking at it, I am unable to duplicate it. Can you verify it wasn't a flask refresh thing?

@rlam3
Copy link
Contributor Author

rlam3 commented Sep 19, 2016

I'm using PAW and terminal and still able to reproduce it. I'm not sure what flask refresh thing you are referring to.

MYUSERNAME$ curl -H "Content-Type: application/json" -X POST -d '{"username":"test1","password":"abc123"}' http://localhost:5001/auth/login
{
  "access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2NsYWltcyI6eyJpcCI6IjEyNy4wLjAuMSIsInR5cGUiOiJyZXN0cmljdGVkIn0sImp0aSI6IjAyOTNmYWE2LTRjMjYtNGJhMS1hNmRjLWUzMDYzNDExNzg2YiIsImV4cCI6MTQ3NDMxOTA0MiwiZnJlc2giOnRydWUsImlhdCI6MTQ3NDMxNTQ0MiwidHlwZSI6ImFjY2VzcyIsIm5iZiI6MTQ3NDMxNTQ0MiwiaWRlbnRpdHkiOiJ0ZXN0MSJ9.LbIzIr9DA4XeRoinDOzp9tmM4R8yHR6ZgLwe3_wqZGueJD5fwoYZO4bTu-MqR0wysU2gW43ULrowYlK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uQ"
MYUSERNAME$ curl -H "Authorization: Bearer $REFRESH" -X POST http://localhost:5001/auth/refresh
{
  "msg": "Missing or invalid claim: jti"
}

@vimalloc
Copy link
Owner

vimalloc commented Sep 19, 2016

Ok, got it. I'm currently using python3, and it looks like that breaks in python2. It is the isinstance check here:

    if 'jti' not in data or not isinstance(data['jti'], str):
        raise JWTDecodeError("Missing or invalid claim: jti")

Let me get the unittests done for this, and I'll go through and make sure it's compatiable for both python2 and python3.

Thanks!

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

No branches or pull requests

2 participants