π 0.3.1 - SessionStorage
Session
This is a supported Redis Based Session Storage for your FastAPI Application, you can use it with any Session Backend.
pip install authx[session]
Note: The requirements in authx[redis]
are not the same used in Sessions features.
Features
- Dependency injection to protect routes
- Compatible with FastAPI's auto-generated docs
- Pydantic models for verifying session data
- Abstract session backend so you can build one that fits your needs
- Abstract frontends to choose how you extract the session ids (cookies, header, etc.)
- Create verifiers based on the session data.
- Compatible with any Redis Configuration.
Redis Configuration
Before setting up our Sessions Storage and our CRUD Backend, we need to configure our Redis Instance.
BasicConfig
is a function that helps us set up the Instance Information like Redis Link Connection or ID Name or Expiration Time.
Default Config
- url of Redis:
redis://localhost:6379/0
- name of sessionId:
ssid
- generator function of
sessionId
:lambda :uuid.uuid4().hex
- expire time of session in redis:
6 hours
import random
from datetime import timedelta
from authx.cache import basicConfig
basicConfig(
redisURL="redis://localhost:6379/1",
sessionIdName="sessionId",
sessionIdGenerator=lambda: str(random.randint(1000, 9999)),
expireTime=timedelta(days=1),
)
- Read the Changelog https://authx.yezz.codes/release/
What's Changed
- chore(dev): Add Sessions Requirements by @yezz123 in #207
- chore(docs): Documented the Functionality of Session Storing by @yezz123 in #208
Full Changelog: 0.3.0...0.3.1