GSpot authentication package for FastApi
Project description
GSpot authentication package
This package allows you to authorize users through a shared redis
Install package
pip install gspot-fastapi-auth
Define env variables
REDIS_AUTH_ACCESS_PREFIX
default ''REDIS_AUTH_DB
default 0REDIS_AUTH_HOST
default 127.0.0.1REDIS_AUTH_PORT
default 6379REDIS_AUTH_PASSWORD
default NoneREDIS_AUTH_TOKEN_STORAGE
default 'headers' should be 'cookies'
Define startapp and shutdown logic
from contextlib import asynccontextmanager
from fastapi import FastAPI
from src.gspot_fastapi_auth import token_config
from gspot_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 gspot_fastapi_auth import UserRedisAuth
@app.get("/")
async def read_root(user=Depends(UserRedisAuth())):
return user.to_dict()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for gspot_fastapi_auth-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 771642ba79702c47fba7ef848822457916300b6b0ecbe4beab6e66e3733c0437 |
|
MD5 | daf4a3a38eb390ee77a993c4b8b557be |
|
BLAKE2b-256 | 4c736bdb719ed36596233e87dfe37c2e9f5c12e6e9cef2dfe93bc9dcdef8c27e |