SessionStore¶
-
class
gafaelfawr.session.SessionStore(key: str, verifier: TokenVerifier, redis: Redis, logger: BoundLogger)¶ Bases:
objectStores and retrieves sessions.
Parameters: - key (
str) – Encryption key for the session store. Must be acryptography.fernet.Fernetkey. - verifier (
gafaelfawr.verify.TokenVerifier) – A token verifier to check the retrieved token. - redis (
aioredis.Redis) – A Redis client configured to talk to the backend store that holds the (encrypted) tokens. - logger (
structlog.BoundLogger) – Logger for diagnostics.
Methods Summary
analyze_handle(handle)Analyze a session handle and return its expanded information. delete_session(key, pipeline)Delete a session. get_session(handle)Retrieve and decrypt the session for a handle. store_session(session, pipeline)Store a session. Methods Documentation
-
analyze_handle(handle: SessionHandle) → Dict[str, Any]¶ Analyze a session handle and return its expanded information.
Parameters: handle ( gafaelfawr.session.SessionHandle) – The session handle to analyze.Returns: output – The contents of the session handle and its underlying session. This will include the session key and secret, the session it references, and the token that session contains. Return type: Dict[ str, Any]
-
delete_session(key: str, pipeline: Pipeline) → None¶ Delete a session.
To allow the caller to batch this with other Redis modifications, the deletion is done using the provided pipeline. The caller is responsible for executing the pipeline.
Parameters: - key (
str) – The key of the session. - pipeline (
aioredis.commands.Pipeline) – The pipeline to use to delete the sesion.
- key (
-
get_session(handle: SessionHandle) → Optional[Session]¶ Retrieve and decrypt the session for a handle.
Parameters: handle ( SessionHandle) – The handle corresponding to the session.Returns: session – The corresponding session, or Noneif no session exists for this session handle.Return type: SessionorNone
-
store_session(session: Session, pipeline: Optional[Pipeline] = None) → None¶ Store a session.
To allow the caller to batch this with other Redis modifications, if a pipeline is provided, the session will be stored but the pipeline will not be executed. In this case, the caller is responsible for executing the pipeline.
Parameters: - session (
Session) – The session to store. - pipeline (
aioredis.commands.Pipeline, optional) – The pipeline in which to store the session.
- session (
- key (