A fastapi simple user and login manager.
- Docker
- Python 3.8
- Poetry
- FastAPI
- Sqlalchemy
- psycopg2
- uvicorn
- pytest
Only tested on Linux (Arch).
Install dependencies :
make install
Start the development database :
make start-db
Build and run a docker image db.dockerfile
that starts a Postgresql
server on port 5432.
Run the service endpoint :
make serve
Run the server at http://localhost:8080
Interactive documentation
- SwaggerUI is running on http://localhost:8080/docs
Default root user
- email : root@example.com
- password: password
Run the tests
make test
⚠️ This will wipe the database content.
User management
- GET /users
- POST /users
- GET /users/<email>
- PUT /users/<email>
- DELETE /users/<email>
Self user
- GET /users/me
- PUT /users/me
- DELETE /users/me
Login
- POST /login
Testing endpoints
- GET /resource/public
- GET /resource/protected
Authorization header
- Authorization: Bearer "token returned by
/login
"
Additional implementation details
Use Postgresql pgcrypto
and uuid-oss
extensions for password hashes and uuid columns.
- Password hashes are managed / checked in database.
- Primary keys are generated using
uuid-oss extension
.