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_PREFIXdefault ''REDIS_AUTH_DBdefault 0REDIS_AUTH_HOSTdefault 127.0.0.1REDIS_AUTH_PORTdefault 6379REDIS_AUTH_PASSWORDdefault NoneREDIS_AUTH_TOKEN_STORAGEdefault '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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gspot_fastapi_auth-0.0.6.tar.gz.
File metadata
- Download URL: gspot_fastapi_auth-0.0.6.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f6f72c6375cdcbf05f60e938de4ba875c4d6b03a2d8b0d93e51fe329515aa66
|
|
| MD5 |
db7d68597d79afaca1154488ea02c1d5
|
|
| BLAKE2b-256 |
51416079191dc4e42cd9f18180379f1452fc9d31522b5718b6eeb12b2b100bcc
|
File details
Details for the file gspot_fastapi_auth-0.0.6-py3-none-any.whl.
File metadata
- Download URL: gspot_fastapi_auth-0.0.6-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
771642ba79702c47fba7ef848822457916300b6b0ecbe4beab6e66e3733c0437
|
|
| MD5 |
daf4a3a38eb390ee77a993c4b8b557be
|
|
| BLAKE2b-256 |
4c736bdb719ed36596233e87dfe37c2e9f5c12e6e9cef2dfe93bc9dcdef8c27e
|