EncryptionKeyStorageStrategy
Interface for key management strategies used in event encryption.
Implementations are responsible for storing, retrieving, and deleting encryption keys for specific data subjects. Supports multi-tenancy via scoped_for_tenant. Used by the Encryption service for key management and crypto-shredding.
Source code in event_sourcery/_event_store/event/encryption.py
delete(subject_id)
Deletes the encryption key for the given subject identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id |
str
|
The subject identifier whose key should be deleted. |
required |
Source code in event_sourcery/_event_store/event/encryption.py
get(subject_id)
Retrieves the encryption key for the given subject identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id |
str
|
The subject identifier. |
required |
Returns:
| Type | Description |
|---|---|
bytes | None
|
bytes | None: The encryption key, or None if not found. |
Source code in event_sourcery/_event_store/event/encryption.py
scoped_for_tenant(tenant_id)
Returns a key storage strategy instance scoped for the given tenant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tenant_id |
TenantId
|
The tenant identifier. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The key storage strategy instance for the tenant. |
Source code in event_sourcery/_event_store/event/encryption.py
store(subject_id, key)
Stores the encryption key for the given subject identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id |
str
|
The subject identifier. |
required |
key |
bytes
|
The encryption key to store. |
required |