Compare commits
3 Commits
b530276df2
...
089aad24c3
| Author | SHA1 | Date | |
|---|---|---|---|
| 089aad24c3 | |||
| 085fe5e03e | |||
| 5ca76813d4 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -25,10 +25,17 @@ env/
|
||||
htmlcov/
|
||||
coverage.xml
|
||||
|
||||
# Lint / type checking
|
||||
.mypy_cache/
|
||||
.ruff_cache/
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
.env.local
|
||||
|
||||
# Docs build artifacts
|
||||
site
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
@@ -38,7 +45,6 @@ Thumbs.db
|
||||
*.swo
|
||||
*~
|
||||
*.tmp
|
||||
site
|
||||
|
||||
# Credentials
|
||||
client_secret_*.json
|
||||
|
||||
@@ -247,6 +247,13 @@
|
||||
"signature": "<bound method Alias.signature of Alias('Callable', 'collections.abc.Callable')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
"kind": "alias",
|
||||
"path": "mail_intake.credentials.redis.Any",
|
||||
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
|
||||
"docstring": null
|
||||
},
|
||||
"TypeVar": {
|
||||
"name": "TypeVar",
|
||||
"kind": "alias",
|
||||
@@ -295,7 +302,7 @@
|
||||
"name": "RedisCredentialStore",
|
||||
"kind": "class",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore",
|
||||
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 137)>",
|
||||
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 145)>",
|
||||
"docstring": "Redis-backed implementation of `CredentialStore`.\n\nThis store persists credentials in Redis and is suitable for\ndistributed and horizontally scaled deployments where credentials\nmust be shared across multiple processes or nodes.\n\nNotes:\n **Responsibilities:**\n\n - This class is responsible only for persistence and retrieval.\n - It does not interpret, validate, refresh, or otherwise manage the\n lifecycle of the credentials being stored.\n\n **Guarantees:**\n\n - The store is intentionally generic and delegates all serialization\n concerns to caller-provided functions.\n - This avoids unsafe mechanisms such as `pickle` and allows\n credential formats to be explicitly controlled and audited.",
|
||||
"members": {
|
||||
"redis": {
|
||||
@@ -337,31 +344,24 @@
|
||||
"name": "load",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.load",
|
||||
"signature": "<bound method Function.signature of Function('load', 80, 105)>",
|
||||
"signature": "<bound method Function.signature of Function('load', 88, 113)>",
|
||||
"docstring": "Load credentials from Redis.\n\nReturns:\n T | None:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If no value exists for the configured key, or if the stored\n payload cannot be successfully deserialized, this method\n returns `None`.\n - The store does not attempt to validate the returned\n credentials or determine whether they are expired or\n otherwise usable."
|
||||
},
|
||||
"save": {
|
||||
"name": "save",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.save",
|
||||
"signature": "<bound method Function.signature of Function('save', 107, 125)>",
|
||||
"signature": "<bound method Function.signature of Function('save', 115, 133)>",
|
||||
"docstring": "Persist credentials to Redis.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials under the same key are overwritten\n - If a TTL is configured, the credentials will expire automatically after the specified duration"
|
||||
},
|
||||
"clear": {
|
||||
"name": "clear",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.clear",
|
||||
"signature": "<bound method Function.signature of Function('clear', 127, 137)>",
|
||||
"signature": "<bound method Function.signature of Function('clear', 135, 145)>",
|
||||
"docstring": "Remove stored credentials from Redis.\n\nNotes:\n **Lifecycle:**\n\n - This operation deletes the configured Redis key if it exists\n - Implementations should treat this method as idempotent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
"kind": "alias",
|
||||
"path": "mail_intake.credentials.redis.Any",
|
||||
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
"signature": "<bound method Alias.signature of Alias('Callable', 'collections.abc.Callable')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
"kind": "alias",
|
||||
"path": "mail_intake.credentials.redis.Any",
|
||||
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
|
||||
"docstring": null
|
||||
},
|
||||
"TypeVar": {
|
||||
"name": "TypeVar",
|
||||
"kind": "alias",
|
||||
@@ -59,7 +66,7 @@
|
||||
"name": "RedisCredentialStore",
|
||||
"kind": "class",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore",
|
||||
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 137)>",
|
||||
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 145)>",
|
||||
"docstring": "Redis-backed implementation of `CredentialStore`.\n\nThis store persists credentials in Redis and is suitable for\ndistributed and horizontally scaled deployments where credentials\nmust be shared across multiple processes or nodes.\n\nNotes:\n **Responsibilities:**\n\n - This class is responsible only for persistence and retrieval.\n - It does not interpret, validate, refresh, or otherwise manage the\n lifecycle of the credentials being stored.\n\n **Guarantees:**\n\n - The store is intentionally generic and delegates all serialization\n concerns to caller-provided functions.\n - This avoids unsafe mechanisms such as `pickle` and allows\n credential formats to be explicitly controlled and audited.",
|
||||
"members": {
|
||||
"redis": {
|
||||
@@ -101,31 +108,24 @@
|
||||
"name": "load",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.load",
|
||||
"signature": "<bound method Function.signature of Function('load', 80, 105)>",
|
||||
"signature": "<bound method Function.signature of Function('load', 88, 113)>",
|
||||
"docstring": "Load credentials from Redis.\n\nReturns:\n T | None:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If no value exists for the configured key, or if the stored\n payload cannot be successfully deserialized, this method\n returns `None`.\n - The store does not attempt to validate the returned\n credentials or determine whether they are expired or\n otherwise usable."
|
||||
},
|
||||
"save": {
|
||||
"name": "save",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.save",
|
||||
"signature": "<bound method Function.signature of Function('save', 107, 125)>",
|
||||
"signature": "<bound method Function.signature of Function('save', 115, 133)>",
|
||||
"docstring": "Persist credentials to Redis.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials under the same key are overwritten\n - If a TTL is configured, the credentials will expire automatically after the specified duration"
|
||||
},
|
||||
"clear": {
|
||||
"name": "clear",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.clear",
|
||||
"signature": "<bound method Function.signature of Function('clear', 127, 137)>",
|
||||
"signature": "<bound method Function.signature of Function('clear', 135, 145)>",
|
||||
"docstring": "Remove stored credentials from Redis.\n\nNotes:\n **Lifecycle:**\n\n - This operation deletes the configured Redis key if it exists\n - Implementations should treat this method as idempotent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
"kind": "alias",
|
||||
"path": "mail_intake.credentials.redis.Any",
|
||||
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,6 +891,13 @@
|
||||
"signature": "<bound method Alias.signature of Alias('Callable', 'collections.abc.Callable')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
"kind": "alias",
|
||||
"path": "mail_intake.credentials.redis.Any",
|
||||
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
|
||||
"docstring": null
|
||||
},
|
||||
"TypeVar": {
|
||||
"name": "TypeVar",
|
||||
"kind": "alias",
|
||||
@@ -939,7 +946,7 @@
|
||||
"name": "RedisCredentialStore",
|
||||
"kind": "class",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore",
|
||||
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 137)>",
|
||||
"signature": "<bound method Class.signature of Class('RedisCredentialStore', 35, 145)>",
|
||||
"docstring": "Redis-backed implementation of `CredentialStore`.\n\nThis store persists credentials in Redis and is suitable for\ndistributed and horizontally scaled deployments where credentials\nmust be shared across multiple processes or nodes.\n\nNotes:\n **Responsibilities:**\n\n - This class is responsible only for persistence and retrieval.\n - It does not interpret, validate, refresh, or otherwise manage the\n lifecycle of the credentials being stored.\n\n **Guarantees:**\n\n - The store is intentionally generic and delegates all serialization\n concerns to caller-provided functions.\n - This avoids unsafe mechanisms such as `pickle` and allows\n credential formats to be explicitly controlled and audited.",
|
||||
"members": {
|
||||
"redis": {
|
||||
@@ -981,31 +988,24 @@
|
||||
"name": "load",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.load",
|
||||
"signature": "<bound method Function.signature of Function('load', 80, 105)>",
|
||||
"signature": "<bound method Function.signature of Function('load', 88, 113)>",
|
||||
"docstring": "Load credentials from Redis.\n\nReturns:\n T | None:\n An instance of type `T` if credentials are present and\n successfully deserialized; otherwise `None`.\n\nNotes:\n **Guarantees:**\n\n - If no value exists for the configured key, or if the stored\n payload cannot be successfully deserialized, this method\n returns `None`.\n - The store does not attempt to validate the returned\n credentials or determine whether they are expired or\n otherwise usable."
|
||||
},
|
||||
"save": {
|
||||
"name": "save",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.save",
|
||||
"signature": "<bound method Function.signature of Function('save', 107, 125)>",
|
||||
"signature": "<bound method Function.signature of Function('save', 115, 133)>",
|
||||
"docstring": "Persist credentials to Redis.\n\nArgs:\n credentials (T):\n The credential object to persist.\n\nNotes:\n **Responsibilities:**\n\n - Any previously stored credentials under the same key are overwritten\n - If a TTL is configured, the credentials will expire automatically after the specified duration"
|
||||
},
|
||||
"clear": {
|
||||
"name": "clear",
|
||||
"kind": "function",
|
||||
"path": "mail_intake.credentials.redis.RedisCredentialStore.clear",
|
||||
"signature": "<bound method Function.signature of Function('clear', 127, 137)>",
|
||||
"signature": "<bound method Function.signature of Function('clear', 135, 145)>",
|
||||
"docstring": "Remove stored credentials from Redis.\n\nNotes:\n **Lifecycle:**\n\n - This operation deletes the configured Redis key if it exists\n - Implementations should treat this method as idempotent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
"kind": "alias",
|
||||
"path": "mail_intake.credentials.redis.Any",
|
||||
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -52,7 +52,7 @@ plugins:
|
||||
handlers:
|
||||
python:
|
||||
paths:
|
||||
- .
|
||||
- ..
|
||||
options:
|
||||
docstring_style: google
|
||||
show_source: false
|
||||
@@ -67,33 +67,34 @@ plugins:
|
||||
show_object_full_path: false
|
||||
show_symbol_type_heading: true
|
||||
site_name: mail_intake
|
||||
docs_dir: docs
|
||||
docs_dir: lib
|
||||
site_dir: ../site/lib
|
||||
nav:
|
||||
- Home: lib/index.md
|
||||
- Home: index.md
|
||||
- Core API:
|
||||
- lib/ingestion/index.md
|
||||
- lib/ingestion/reader.md
|
||||
- ingestion/index.md
|
||||
- ingestion/reader.md
|
||||
- Domain Models:
|
||||
- lib/models/index.md
|
||||
- lib/models/message.md
|
||||
- lib/models/thread.md
|
||||
- models/index.md
|
||||
- models/message.md
|
||||
- models/thread.md
|
||||
- Provider Adapters:
|
||||
- lib/adapters/index.md
|
||||
- lib/adapters/base.md
|
||||
- lib/adapters/gmail.md
|
||||
- adapters/index.md
|
||||
- adapters/base.md
|
||||
- adapters/gmail.md
|
||||
- Authentication & Storage:
|
||||
- lib/auth/index.md
|
||||
- lib/auth/base.md
|
||||
- lib/auth/google.md
|
||||
- lib/credentials/index.md
|
||||
- lib/credentials/store.md
|
||||
- lib/credentials/pickle.md
|
||||
- lib/credentials/redis.md
|
||||
- auth/index.md
|
||||
- auth/base.md
|
||||
- auth/google.md
|
||||
- credentials/index.md
|
||||
- credentials/store.md
|
||||
- credentials/pickle.md
|
||||
- credentials/redis.md
|
||||
- Normalization & Parsing:
|
||||
- lib/parsers/index.md
|
||||
- lib/parsers/body.md
|
||||
- lib/parsers/headers.md
|
||||
- lib/parsers/subject.md
|
||||
- parsers/index.md
|
||||
- parsers/body.md
|
||||
- parsers/headers.md
|
||||
- parsers/subject.md
|
||||
- Configuration & Errors:
|
||||
- lib/config.md
|
||||
- lib/exceptions.md
|
||||
- config.md
|
||||
- exceptions.md
|
||||
@@ -25,7 +25,7 @@ responsibility of authentication provider implementations.
|
||||
"""
|
||||
|
||||
from collections.abc import Callable
|
||||
from typing import TypeVar
|
||||
from typing import Any, TypeVar
|
||||
|
||||
from mail_intake.credentials.store import CredentialStore
|
||||
|
||||
@@ -57,7 +57,7 @@ class RedisCredentialStore(CredentialStore[T]):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
redis_client,
|
||||
redis_client: Any,
|
||||
key: str,
|
||||
serialize: Callable[[T], bytes],
|
||||
deserialize: Callable[[bytes], T],
|
||||
@@ -66,10 +66,18 @@ class RedisCredentialStore(CredentialStore[T]):
|
||||
"""
|
||||
Initialize a Redis-backed credential store.
|
||||
|
||||
Callers supply all runtime dependencies: ``redis_client`` is an
|
||||
initialized Redis client instance, ``key`` names the storage key,
|
||||
``serialize``/``deserialize`` are the encoding and decoding callables,
|
||||
and ``ttl_seconds`` optionally limits credential lifetime.
|
||||
Args:
|
||||
redis_client (Any):
|
||||
Initialized Redis client instance used for persistence.
|
||||
key (str):
|
||||
Storage key under which credentials are persisted.
|
||||
serialize (Callable[[T], bytes]):
|
||||
Callable that encodes credentials to bytes for storage.
|
||||
deserialize (Callable[[bytes], T]):
|
||||
Callable that decodes stored bytes back into credentials.
|
||||
ttl_seconds (int | None):
|
||||
Optional time-to-live in seconds after which stored
|
||||
credentials expire automatically. ``None`` disables expiry.
|
||||
"""
|
||||
self.redis = redis_client
|
||||
self.key = key
|
||||
|
||||
Reference in New Issue
Block a user