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

#165273469 Add jwt authenticatication #8

Merged
merged 1 commit into from
Apr 26, 2019

Conversation

engjames
Copy link
Contributor

@engjames engjames commented Apr 25, 2019

What does this PR do?
-Add a jwt authentication

Description of Task to be completed?

  • Add PyJWT to requirements.txt file
  • Enable jwt authentication in settings.py
  • Modify urls to cater for jwt authentication
  • Add a method in the models that generates a token
  • Add a method to check and verify for authorization header
  • Return a response with a token, message and username upon successful generation.
    For a person to get a token, he has to first create an account using http://127.0.0.1:8000/api/users/
    The body should be in the form
    {
    "user": {
    "username": "francis",
    "email": "francis@gmail.com",
    "password": "123456789"
    }
    }
    Then login to get a token using http://127.0.0.1:8000/api/users/login/
    The body should be in the form
    {
    "user":{
    "email": "francis@gmail.com",
    "password": "123456789"
    }
    }
    image

What are the relevant pivotal tracker stories?
#165273469

@joelmugaya @Baalmart @mwinel @3Nakajugo @sanya-kenneth @KabohaJeanMark @archbishop12 @

message = "User does not exist in the database."
raise exceptions.AuthenticationFailed(message)
if not user.is_active:
message = "User is deactivated."
Copy link
Contributor

Choose a reason for hiding this comment

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

Return an appropriate message. eg.

Suggested change
message = "User is deactivated."
message = "User is not active."

@@ -1,3 +1,4 @@
"""Imports relevant to our class."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding a comment but try and avoid unnecessary changes

@@ -1,3 +1,4 @@
"""Import relevant dependencies."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding a comment but try and avoid unnecessary changes

requirements.txt Outdated
@@ -3,7 +3,6 @@ attrs==19.1.0
certifi==2019.3.9
chardet==3.0.4
coverage==4.5.3
coveralls==1.7.0
Copy link
Contributor

Choose a reason for hiding this comment

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

We need this package please fix

@engjames engjames force-pushed the ft-generate-jwt-token-165273469 branch from ebf57a7 to 9d13ab6 Compare April 25, 2019 17:48
@engjames engjames force-pushed the ft-generate-jwt-token-165273469 branch from 9d13ab6 to 9f1d861 Compare April 25, 2019 19:42
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-8 April 25, 2019 19:56 Inactive
@engjames engjames force-pushed the ft-generate-jwt-token-165273469 branch from 9f1d861 to baa6300 Compare April 26, 2019 05:16
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-8 April 26, 2019 05:16 Inactive
- Add PyJWT to requirements.txt file
- Enable jwt authentication in settings.py
- Modify urls to cater for jwt authentication
- Add a method in the models that generates a token
- Add a method to check and verify for authorization header
- Return a response with a token, message and username upon successful generation.

[Starts #165273469]
Copy link

@archibishop archibishop left a comment

Choose a reason for hiding this comment

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

LGMT @engjames I am merging this. Good work.

@archibishop archibishop merged commit b4d59c2 into develop Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants