Default auth service based on FastApi framework
Installation
$ pip install fastapi-auth-user
or
for poetry:
$ poetry init
$ poetry add fastapi-auth-user
Example
Create it
- Create a file
main.pywith:
import uvicorn
from fastapi_auth_user import auth_app
if __name__ == "__main__":
uvicorn.run(auth_app, host="localhost", port=3000)
Run it
Run the server with:
$ poetry run main.py or $ python3 main.py
INFO: Started server process [12484]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://localhost:3000 (Press CTRL+C to quit)
Check it
Open your browser at http://localhost:3000/docs.
You will see:
You already created an API that:
- All method CRUD for USER model`.
- All method CRUD for Role model`.
- Login user with oauth2
- Profile this user
Env file
DB_USER=<YOU USER NAME DB> #'postgres'
DB_PASSWORD=<YOU DATABASE PASSWORD> #'root'
DB_HOST=<YOU DATABASE HOST> #'localhost'
DB_NAME=<YOU DATABASE NAME> #'auth_db'
DATABASE_URL=<YOU DATABASE URL> #'postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}'
ACCESS_TOKEN_EXPIRE_MINUTES=<TIME FOR TOKEN> #30
SECRET_KEY=<SECRET KEY> #'secret_key'
ALGORITHM=<HASH ALGORITHM> #'HS256'
Release files for fastapi-auth-user 0.1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_auth_user-0.1.3.0.tar.gz | 15.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_auth_user-0.1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.8 kB
Release files / fastapi_auth_user-0.1.3.0.tar.gz
| Download URL | fastapi_auth_user-0.1.3.0.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
254038f0fc4eabc99d8c664adbcbe05403a8e6954b548486df47c1e621996aaf
|
|
BLAKE2b-256 checksum How to use checksums |
4fd8744111dbbf938c10fb796bbd525b897b6d3e52fbbba7775dd10464a8e1cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Windows/10
|
Release files / fastapi_auth_user-0.1.3.0-py3-none-any.whl
| Download URL | fastapi_auth_user-0.1.3.0-py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3dab8e693a2714de8bc42aebd0824d529d8a0e094f0b08a0bc2f57b0199b2f3
|
|
BLAKE2b-256 checksum How to use checksums |
97d81a465c51d315e5546ee0c32428437f6418fa8df9460c459901f0946e6874
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Windows/10
|