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
REDIS_AUTH_DB
REDIS_AUTH_HOST
REDIS_AUTH_PORT
REDIS_AUTH_PASSWORD
REDIS_AUTH_TOKEN_STORAGE
- 'headers' or '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.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa476d01a9d3f4e5318763af1504d3add712d2e66296d3ca7f80699e6646f79f |
|
MD5 | 3ddb5ed1a7ac05570d1b4942644826eb |
|
BLAKE2b-256 | 35852f1546c1283d0ec9691d5061bbfc7b8193312544eaa3c07b7ad004832639 |