update layercake version
This commit is contained in:
@@ -45,12 +45,12 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
|
||||
self,
|
||||
action: str,
|
||||
/,
|
||||
collect: DynamoDBCollection,
|
||||
collection: DynamoDBCollection,
|
||||
audit_attrs: tuple[str, ...] = (),
|
||||
retention_days: int | None = LOG_RETENTION_DAYS,
|
||||
) -> None:
|
||||
self.action = action
|
||||
self.collect = collect
|
||||
self.collection = collection
|
||||
self.audit_attrs = audit_attrs
|
||||
self.retention_days = retention_days
|
||||
|
||||
@@ -80,7 +80,7 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
|
||||
else None
|
||||
)
|
||||
|
||||
self.collect.put_item(
|
||||
self.collection.put_item(
|
||||
key=KeyPair(
|
||||
# Post-migration: remove `delimiter` and update prefix
|
||||
# from `log` to `logs` in ComposeKey.
|
||||
|
||||
@@ -46,11 +46,11 @@ class TenantMiddleware(BaseMiddlewareHandler):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
collect: DynamoDBCollection,
|
||||
collection: DynamoDBCollection,
|
||||
/,
|
||||
header: str = 'X-Tenant',
|
||||
) -> None:
|
||||
self.collect = collect
|
||||
self.collection = collection
|
||||
self.header = header
|
||||
|
||||
def handler(
|
||||
@@ -69,7 +69,7 @@ class TenantMiddleware(BaseMiddlewareHandler):
|
||||
tenant=_tenant(
|
||||
app.current_event.headers.get(self.header),
|
||||
app.context.get('user'), # type: ignore
|
||||
collect=self.collect,
|
||||
collection=self.collection,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -85,7 +85,7 @@ def _tenant(
|
||||
tenant_id: str | None,
|
||||
user: User,
|
||||
/,
|
||||
collect: DynamoDBCollection,
|
||||
collection: DynamoDBCollection,
|
||||
) -> Tenant:
|
||||
"""Get a Tenant instance based on the provided tenant_id
|
||||
and user's access permissions.
|
||||
@@ -96,7 +96,7 @@ def _tenant(
|
||||
The identifier of the tenant. Must not be None or empty.
|
||||
user : User
|
||||
The user attempting to access the tenant.
|
||||
collect : DynamoDBCollection
|
||||
collection : DynamoDBCollection
|
||||
The DynamoDB collection used to retrieve tenant information.
|
||||
|
||||
Returns
|
||||
@@ -117,7 +117,7 @@ def _tenant(
|
||||
raise BadRequestError('Missing tenant')
|
||||
|
||||
# Ensure user has ACL
|
||||
collect.get_item(
|
||||
collection.get_item(
|
||||
KeyPair(user.id, ComposeKey(tenant_id, prefix='acls')),
|
||||
exc_cls=ForbiddenError,
|
||||
)
|
||||
@@ -126,5 +126,5 @@ def _tenant(
|
||||
if tenant_id == '*':
|
||||
return Tenant(id=tenant_id, name='default')
|
||||
|
||||
obj = collect.get_item(KeyPair(tenant_id, '0'), exc_cls=NotFoundError)
|
||||
obj = collection.get_item(KeyPair(tenant_id, '0'), exc_cls=NotFoundError)
|
||||
return Tenant.model_validate(obj)
|
||||
|
||||
Reference in New Issue
Block a user