Introduction

Part 3, Lesson 1



In part 3, we'll add database migrations along with password hashing in order to implement token-based authentication to the users service with JSON Web Tokens (JWTs). We'll then turn our attention to the client and add React Router to the React app to enable client-side routing along with client-side authentication.

Objectives

By the end of part 3, you will be able to...

  1. Use Flask Migrate to handle database migrations
  2. Configure Flask Bcrypt for password hashing
  3. Implement user authentication with JWTs
  4. Write tests to create and verify JWTs and user authentication
  5. Use React Router to define client-side routes in React
  6. Build UI components with React Bootstrap
  7. Explain the difference between user authentication and authorization
  8. Test user interactions with Jest and Enzyme
  9. Implement user authorization

App

flask tdd logo

Check out the live apps, running on EC2 -

  1. Production
  2. Staging

You can also test out the following endpoints...

Endpoint HTTP Method Authenticated? Result
/auth/register POST No register user
/auth/login POST No log in user
/auth/logout GET Yes log out user
/auth/status GET Yes check user status
/users GET No get all users
/users/:id GET No get single user
/users POST Yes (admin) add a user
/users/ping GET No sanity check

Finished code for part 3: https://github.com/realpython/testdriven-app/releases/tag/part3

Dependencies

You will use the following dependencies in part 3:

  1. Flask-Migrate v2.1.1
  2. Flask-Bcrypt v0.7.1
  3. PyJWT v1.5.3
  4. react-router-dom v4.2.2
  5. React Bootstrap v0.31.5
  6. React Router Bootstrap v0.24.4

Introduction

In part 3, we'll add database migrations along with password hashing in order to implement token-based authentication to the users service with JSON Web Tokens (JWTs). We'll then turn our attention to the client and add React Router to the React app to enable client-side routing along with client-side authentication.

Objectives

By the end of part 3, you will be able to...

  1. Use Flask Migrate to handle database migrations
  2. Configure Flask Bcrypt for password hashing
  3. Implement user authentication with JWTs
  4. Write tests to create and verify JWTs and user authentication
  5. Use React Router to define client-side routes in React
  6. Build UI components with React Bootstrap
  7. Explain the difference between user authentication and authorization
  8. Test user interactions with Jest and Enzyme
  9. Implement user authorization

App

flask tdd logo

Check out the live apps, running on EC2 -

  1. Production
  2. Staging

You can also test out the following endpoints...

Endpoint HTTP Method Authenticated? Result
/auth/register POST No register user
/auth/login POST No log in user
/auth/logout GET Yes log out user
/auth/status GET Yes check user status
/users GET No get all users
/users/:id GET No get single user
/users POST Yes (admin) add a user
/users/ping GET No sanity check

Finished code for part 3: https://github.com/realpython/testdriven-app/releases/tag/part3

Dependencies

You will use the following dependencies in part 3:

  1. Flask-Migrate v2.1.1
  2. Flask-Bcrypt v0.7.1
  3. PyJWT v1.5.3
  4. react-router-dom v4.2.2
  5. React Bootstrap v0.31.5
  6. React Router Bootstrap v0.24.4