Skip to main content

auth user

Project description

FastAPI

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.py with:
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: img.png

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'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_auth_user-0.1.2.4.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

fastapi_auth_user-0.1.2.4-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_auth_user-0.1.2.4.tar.gz.

File metadata

  • Download URL: fastapi_auth_user-0.1.2.4.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.0 Windows/10

File hashes

Hashes for fastapi_auth_user-0.1.2.4.tar.gz
Algorithm Hash digest
SHA256 9d9eb27c059569f36d17fc27bb645e2463adbf5bef3df37c6362195144a9c9b8
MD5 6fa87d7c0bec3667f96a43e426d40ec3
BLAKE2b-256 6d3f2d45e8a824192474ed6ffea2706a1c178d0cd3ea7ea8470198192b5ad758

See more details on using hashes here.

File details

Details for the file fastapi_auth_user-0.1.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_auth_user-0.1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c2dd53106ece2a85e46cde6037632b29ea4ccae3540b00544d1e0d1e2384cec7
MD5 83518d11a1153132d00c923793c59da7
BLAKE2b-256 6f53aecaa55167f040964979f1881678358d386e1e40b5470544d6f47528b5d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page