Skip to main content

Barter authentication package

This package allows you to authorize users through a shared redis

Install package

pip install bater-fastapi-auth

Define env variables

  • REDIS_AUTH_ACCESS_PREFIX default ''
  • REDIS_AUTH_DB default 0
  • REDIS_AUTH_HOST default 127.0.0.1
  • REDIS_AUTH_PORT default 6379
  • REDIS_AUTH_PASSWORD default None
  • REDIS_AUTH_TOKEN_STORAGE default 'headers' should be 'cookies'

Define startapp and shutdown logic

from contextlib import asynccontextmanager

from fastapi import FastAPI

from src.bater_fastapi_auth import token_config
from bater_fastapi_auth.providers import RedisSingleton

@asynccontextmanager
async def lifespan(app: FastAPI):
    RedisSingleton.init_redis(
        token_config.HOST,
        token_config.PORT,
        token_config.DB,
        token_config.PASSWORD
    )
    yield
    await RedisSingleton().close()


app = FastAPI(lifespan=lifespan)

Use in view

from bater_fastapi_auth import UserRedisAuth

@app.get("/")
async def read_root(user=Depends(UserRedisAuth())):
    return user.to_dict()

Metadata

Release files for barter-fastapi-auth 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for barter-fastapi-auth 0.1.1
File Size Uploaded Provenance
barter_fastapi_auth-0.1.1.tar.gz 6.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for barter-fastapi-auth 0.1.1
File Interpreter ABI Platform
barter_fastapi_auth-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / barter_fastapi_auth-0.1.1.tar.gz

Download URL barter_fastapi_auth-0.1.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8d7d69eaf453218e0131b173fb752afca00abf30c68dac26fb3405caebe81116
BLAKE2b-256 checksum
How to use checksums
dd5db27bc97916dd4b2e3bbb0f853f2f5f7337893f13409568ce58277df23267
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / barter_fastapi_auth-0.1.1-py3-none-any.whl

Download URL barter_fastapi_auth-0.1.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ea668425c224c5d5edafa6f033681a82408441ba06cd651f2867c1f182ba091
BLAKE2b-256 checksum
How to use checksums
eeba37add2bb6544bcb6f049592a9705161d3e570b5b7103da07556d6ef65f07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Security for barter-fastapi-auth 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page