- customer
- admin
- vendor
-
- They have different access control on the project.
- Enum types
- Abstract model like common model
- RBAC with dependenies and routes.
- Datetime in SQLAlchemy and Pydantic
- Alembic = database migrations
- Alembic = database migrations
- sqladmin = SQLAlchemy Admin
SRL | METHOD | ROUTE | FUNCTIONALITY | Required Fields | ACCESS |
---|---|---|---|---|---|
1 | POST | /auth/token |
Login user | email, password | All users |
2 | POST | /auth/users/ |
Create new user | email, password | Anyone |
3 | GET | /auth/users/ |
Get all users list | None | admin |
4 | GET | /auth/users/me/ |
Get current user details | None | authorized |
5 | GET | /auth/users/{user_id} |
Get indivisual users details | None | Admin |
6 | PATCH | /auth/users/{user_id} |
Update the user partially | email, password, is_active, role | Admin |
7 | DELETE | auth/users/{user_id} |
Delete the user | None | admin |
8 | GET | / |
Home page | None | anyone |
9 | GET | /admin |
Admin Dashboard | None | admin_ |
Python (3.11.6)
FastAPI (0.108.0)
pydantic (2.5.3)
SQLAlchemy == 2.0.25
starlette == 0.32.0.post1
uvicorn == 0.25.0
python-jose == 3.3.0
alembic == 1.13.1
SQLite
The first thing to do is to clone the repository:
$ https://github.com/MahmudJewel/FastAPI-Role-based-auth
Create a virtual environment to install dependencies in and activate it:
$ cd FastAPI-jwt-auth
$ python -m venv venv
$ source venv/bin/activate
Then install the dependencies:
(venv)$ pip install -r requirements.txt
Note the (venv)
in front of the prompt. This indicates that this terminal
session operates in a virtual environment set up by virtualenv2
.
Once pip
has finished downloading the dependencies:
(venv)$ uvicorn core.main:app --reload