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.1.8.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.1.8-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: securely-0.1.8.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.1.8.tar.gz
Algorithm Hash digest
SHA256 719f6070cfbd8e5f51d92ac421b887dc6514907ef002b0b9cdfd6b2818ccb7ca
MD5 b17c63e14cdd59986cc579f0633548e0
BLAKE2b-256 3a062eefac2a92fe617f1baabd8aef0ab051deecee3dec9e9d58aa241b13c87b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: securely-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 2.8 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.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ff5cf85ae397b889dbb771c7ea85a3bd6ce708fd173f3eab50577a3c03fe42bf
MD5 5296a5f41b7c6ec02bd99a29f4ddc78e
BLAKE2b-256 66c112540110bf098c042da8422335abb71612c6d2846d1b4a62f00a0923708d

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