Follow instructions to install the latest version of python for your platform in the python docs
We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organaized. Instructions for setting up a virual enviornment for your platform can be found in the python docs
Once you have your virtual environment setup and running, install dependencies by naviging to the /backend
directory and running:
pip install -r requirements.txt
This will install all of the required packages we selected within the requirements.txt
file.
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
SQLAlchemy and Flask-SQLAlchemy are libraries to handle the lightweight sqlite database. Since we want you to focus on auth, we handle the heavy lift for you in
./src/database/models.py
. We recommend skimming this code first so you know how to interface with the Drink model. -
jose JavaScript Object Signing and Encryption for JWTs. Useful for encoding, decoding, and verifying JWTS.
From within the ./src
directory first ensure you are working using your created virtual environment.
Each time you open a new terminal session, run:
export FLASK_APP=api.py;
To run the server, execute:
flask run --reload
The --reload
flag will detect file changes and restart the server automatically.
- DONE Create a new Auth0 Account
- DONE Select a unique tenant domain https://jbe.eu.auth0.com/authorize?audience=Drinks&response_type=token&client_id=KfdmrtBtLZ1BHiBcnnuiaOIF8cE1zI77&redirect_uri=http://localhost:8100/login-results
- DONE Create a new, single page web application
- DONE Create a new API
- in API Settings:
- DONE Enable RBAC
- DONE Enable Add Permissions in the Access Token
- in API Settings:
- DONE Create new API permissions:
get:drinks-detail
post:drinks
patch:drinks
delete:drinks
- DONE Create new roles for:
- DONE Barista
- DONE can
get:drinks-detail
- DONE can
- DONE Manager
- DONE can perform all actions
- DONE Barista
- Test your endpoints with Postman.
- Register 2 users - assign the Barista role to one and Manager role to the other.
- [email protected] (Coffee123!)
- eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1FTXdRa1ZFT0VKRU1USkROakpGTkRRME4wWkNPVGswTUVZeVJVRkVOekkwUXpaRk1FVTFOQSJ9.eyJpc3MiOiJodHRwczovL2piZS5ldS5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NWVhZGRmY2QwMmIxNzcwYmU0NzU5NzEyIiwiYXVkIjoiRHJpbmtz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wLQEu60ksdaEFNQE4JPvqeffrn8V3gIWB3PI6ayfLpsraV94J3Xjru5IW3ihBWPgK3jNs9AlqQGw_rxENRH-lo_rp6gPM4Kd42o5HeyfqVD3O_HLGd8SAXvGLzbBUKdM_lVcSFqR-eGNXH4DBGyya3F38fpg
- [email protected] (Coffee123!)
- Sign into each account and make note of the JWT.
- Import the postman collection
./starter_code/backend/udacity-fsnd-udaspicelatte.postman_collection.json
- Right-clicking the collection folder for barista and manager, navigate to the authorization tab, and including the JWT in the token field (you should have noted these JWTs).
- Run the collection and correct any errors.
- Export the collection overwriting the one we've included so that we have your proper JWTs during review!
- Register 2 users - assign the Barista role to one and Manager role to the other.
There are @TODO
comments throughout the ./backend/src
. We recommend tackling the files in order and from top to bottom:
./src/auth/auth.py
./src/api.py