Skip to content

Conversation

@tecoholic
Copy link

No description provided.

@pep8speaks
Copy link

pep8speaks commented Aug 26, 2018

Hello @tecoholic! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on January 01, 2019 at 11:13 Hours UTC

@coveralls
Copy link

coveralls commented Aug 26, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling fa51fa8 on tecoholic:master into c5f32c3 on vimalloc:master.

Copy link
Owner

@vimalloc vimalloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a few minor nits here, but all and all this looks good 👍

if username != 'test' or password != 'test':
return jsonify({"msg": "Bad username or password"}), 401

user = {id: 1, username: 'test'}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be more idomatic if we passed it in via the @jwt.user_claims_loader and accessing it later via get_jwt_claims()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the claims loader function takes only one argument. I need to pass both the username and the refresh_jti when creating the access token. So had to do it manually

@jwt_required
def logout():
access_jti = get_raw_jwt()["jti"]
refresh_jti = get_raw_jwt()["identity"]["refresh_jti"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to above, I think it would be more idiomatic if we pulled the token out of the get_jwt_claims() instead of the identity.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, how do i go about using black list loader with a database like postgres?

def refresh():
current_user = get_jwt_identity()
refresh_jti = get_raw_jwt()['jti']
current_user['refresh_jti'] = refresh_jti
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here regarding the user_claims_loader

@tecoholic
Copy link
Author

I have made a few more changes to the example. Kindly review

refresh_token = create_refresh_token(identity=user)

# Embed the refresh token's jti in the access_token
user["refresh_jti"] = get_jti(refresh_token)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like having having this data stored in what will become the current_user for the JWT. It complicates things, especially when using the complex objects from token and vice versa features in this extension. Could we use the @jwt.user_claims_loader instead to put the data into the JWT, then access it via get_jwt_claims() instead of current_user bellow?

@vimalloc
Copy link
Owner

vimalloc commented Jan 9, 2019

I left some comments on your pull request, if you could take a look at them 👍

@decaz
Copy link
Contributor

decaz commented Aug 5, 2019

If this PR is still alive let me notice that the filename should be fixed: blacklist_both_tokens.py.


.. literalinclude:: ../examples/blacklist.py

Sometimes there will be situations where we would want to backlist both the access token and the refresh token in the logout call. It could be done by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... to blacklist both ...

we could write the login, logout and refresh functions as:


.. literalinclude:: ../examples/backlist_both_tokens.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blacklist_both_tokens.py

@tecoholic
Copy link
Author

I am closing this down. It has been a year and I haven't found time to do it the right way. Will try again with new code base sometime later.

@tecoholic tecoholic closed this Aug 23, 2019
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

Successfully merging this pull request may close these issues.

6 participants