Redis
mail_intake.credentials.redis
Redis-backed credential persistence for Mail Intake.
Summary
This module provides a Redis-based implementation of the
CredentialStore abstraction, enabling credential persistence
across distributed and horizontally scaled deployments.
The Redis credential store is designed for environments where authentication credentials must be shared safely across multiple processes, containers, or nodes, such as container orchestration platforms and microservice architectures.
Key characteristics: - Distributed-safe, shared storage using Redis - Explicit, caller-defined serialization and deserialization - No reliance on unsafe mechanisms such as pickle - Optional time-to-live (TTL) support for automatic credential expiry
This module is responsible solely for persistence concerns. Credential validation, refresh, rotation, and acquisition remain the responsibility of authentication provider implementations.
Classes
RedisCredentialStore
Bases: CredentialStore[T]
Redis-backed implementation of CredentialStore.
This store persists credentials in Redis and is suitable for distributed and horizontally scaled deployments where credentials must be shared across multiple processes or nodes.
Notes
Responsibilities:
1 2 | |
Guarantees:
1 2 | |
Initialize a Redis-backed credential store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
redis_client |
Any
|
An initialized Redis client instance (for example, |
required |
key |
str
|
The Redis key under which credentials are stored. Callers are responsible for applying appropriate namespacing to avoid collisions. |
required |
serialize |
Callable[[T], bytes]
|
A callable that converts a credential object of type |
required |
deserialize |
Callable[[bytes], T]
|
A callable that converts a |
required |
ttl_seconds |
Optional[int]
|
Optional time-to-live (TTL) for the stored credentials, expressed in seconds. When provided, Redis will automatically expire the stored credentials after the specified duration. If |
None
|
Functions
clear
Remove stored credentials from Redis.
Notes
Lifecycle:
1 2 | |
load
Load credentials from Redis.
Returns:
| Type | Description |
|---|---|
Optional[T]
|
Optional[T]:
An instance of type |
Notes
Guarantees:
1 2 | |
save
Persist credentials to Redis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credentials |
T
|
The credential object to persist. |
required |
Notes
Responsibilities:
1 2 | |