Skip to content

Conversation

billk97
Copy link

@billk97 billk97 commented Mar 6, 2020

  • Added Json web token support
  • Tried to follow previews comments if i forgot something i will fix it
  • Tried to add some test and didn't have much success.
  • Added in requirements.txt
pyjwt==1.7.1

Fill free to make any observations and i will try to fix them.

@wraps(f)
def decorated(*args, **kwargs):
token = None
if 'x-access-token' in request.headers:

Choose a reason for hiding this comment

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

Why not use the plain Authorization: Bearer <token> headers for this? 😄

if 'x-access-token' in request.headers:
token = request.headers['x-access-token']
if not token:
jsonify({'message': 'Token is missing'}), 401

Choose a reason for hiding this comment

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

No need to jsonify stuff here, just return the dict and the status code!

"""
Generats a Jwt given a username more could be added in the future
"""
token = jwt.encode({'username': username,

Choose a reason for hiding this comment

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

I think we should rename username to sub, and also add the user's name in the name field.

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.

3 participants