Skip to content

engineer-developer/Fastapi_Form-based-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fastapi authentication

Property Value
Authentication type Form based auth
Credentials email & password
Access-token type JWT
Access-token stored in COOKIE

For authentication uses form, where user input username and password.
If input data is valid, will be created jwt-token and placed it in COOKIES.


The project has implemented:

  • Super_admin can add to database users with different roles.
  • Users can pass authentication with email and password placed in form.
  • A JWT-token is generated during the authentication process and placed in COOKIES.
  • Authenticated user can access endpoints via GET methods
  • Authenticated admins can access endpoints via GET, POST, PUT, DELETE methods
  • Logout process implemented by deleting access-token from cookie.

Prepare virtual enviroinment

The project uses poetry to install dependencies.

  • To install dependencies in project dir run shell-command:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry shell &&
poetry lock

Prepare database

The postgres database is used for data storage

  • For launch postgres database in docker container run command:
docker compose up -d

Prepare environments

Needed environments are placed in .env file
  • You must create and fill in the .env file by analogy with the .env.template file

Run project

You can run project with shell-command:
cd ./src && 
uvicorn "loader:app"

Logging as super_admin

You can log as admin with follow credentials:

Tests

The tests are implemented with pytest.
To be able to run tests you should have database with name "pytest_db".

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published