Skip to content

πŸ”– 0.3.1 - SessionStorage

Compare
Choose a tag to compare
@yezz123 yezz123 released this 15 Jan 14:29
· 971 commits to main since this release
cedd08e

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),
)

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