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

```python
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.6.tar.gz (2.6 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.6-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: securely-0.1.6.tar.gz
  • Upload date:
  • Size: 2.6 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.6.tar.gz
Algorithm Hash digest
SHA256 814accea7c4c2dfa7bb79630ccb78b5b806ece03117aa85bf037fa6e0b08952a
MD5 f687ecc77cd573821d2a2c6d2ea5c820
BLAKE2b-256 c7ebbc41394957ee1abb508cdb7e73cd244b56bc043b953f5d07e50f17543da6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: securely-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6fb6e56acee8e86de5d284cad5c8c6e649e49123d3e990e14640e14af4f1788f
MD5 62a5ce908b638521db06387270234501
BLAKE2b-256 205a38304b3c8d4a85760b4f98fccb37594c5d5d05d772e8646bb20f76b9ab18

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