Skip to main content

This package will help you while authorization and authentication in fastapi

Project description

Source code:https://github.com/coderxuz/securely

Securely

Securely is a Python package that helps with authentication and authorization in FastAPI applications.

Installation

You can install the package via pip:

pip install securely

Quick start

from securely import Auth
from fastapi import FastAPI


from datetime import timedelta

app = FastAPI()

auth = Auth(
    secret_key="bla bla",
    access_token_expires=timedelta(days=1),
    refresh_token_expires=timedelta(days=7),
)

just_db = [{"username": "john", "password": "gdfdfgdgdrgdr"}]


@app.post("/login")
async def login(data: dict):
    new_user = {"username": data.get("username")}

    new_user["password"] = auth.hash_password(password=data.get("password"))

    just_db.append(new_user)

    tokens = auth.create_tokens(subject=new_user.get("username"))

    return tokens

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

securely-0.2.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

securely-0.2.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file securely-0.2.0.tar.gz.

File metadata

  • Download URL: securely-0.2.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for securely-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d13df10a7734fee6cb9858f81e66b827707940da2c3e62d918b8847a6bef8f15
MD5 697dba04e989d5aa6f1a7b0f2925e580
BLAKE2b-256 089855ff804761dba66e36eafe87701b79ff4ba6e467e58ab792b0e882b7bbb1

See more details on using hashes here.

File details

Details for the file securely-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: securely-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for securely-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbe33e286654e0e05caca7daa66dcb9c07bb05eca4eff2e137e240ca984cfe49
MD5 64478a4ba7e148240570e0f960becba0
BLAKE2b-256 1a5c5ded031b22ea15126234b73a4e58d1a9b472dbf54b2063301d5004dcac85

See more details on using hashes here.

Supported by

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