Skip to content

Conversation

@KMaina
Copy link
Owner

@KMaina KMaina commented Sep 26, 2018

What does this PR do?

Add JWT functionality for authorization

Description of Task to be completed?

Have a token generated and only allow a user to access certain endpoints if the token is valid

How should this be manually tested?

  • Clone the repo locally.

  • cd into Fast-Food-Fast-API folder

  • Create a .env file and add the following configurations

export FLASK_APP = run.py
export FLASK_ENV = development
export SECRET_KEY = 'Anything-you-want'
  • Create a virtual environment using the command virtualenv <environment name>

  • Run the app using the command flask run

  • Navigate to the POST api/v1/users endpoint and use the JSON object below

{
            "name" = "Ken Maina", 
            "password" =  "Passing", 
            "username" = "Ken",
            "email" =  "ken@me.com",
            "address" =  "Langata, Nairobi",
            "telephone" =  "+722222222",
            "admin" = true
}
  • Navigate to the POST api/v1/users/login endpoint and use the JSON object below
{
    "username" : "Ken",
    "password" : "Passing"
}
  • Grab the token generated in order to use it as a header to ensure that you are authenticated
  • Navigate to GET api/v1/users endpoint, set the token and you are authorized

What are the relevant pivotal tracker stories?

#160784176

@coveralls
Copy link

Pull Request Test Coverage Report for Build 48

  • 77 of 99 (77.78%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-5.09%) to 81.395%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/api/v1/views_users.py 24 25 96.0%
app/api/v1/models.py 23 44 52.27%
Totals Coverage Status
Change from base Build 41: -5.09%
Covered Lines: 140
Relevant Lines: 172

💛 - Coveralls

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