wip
This commit is contained in:
@@ -63,7 +63,15 @@ class TenantMiddleware(BaseMiddlewareHandler):
|
||||
next_middleware: NextMiddleware,
|
||||
) -> Response:
|
||||
context = app.current_event.request_context.authorizer.get_lambda
|
||||
tenant = app.current_event.headers.get('x-tenant')
|
||||
auth_flow_type = context.get('auth_flow_type')
|
||||
|
||||
match auth_flow_type, tenant:
|
||||
case AuthFlowType.API_AUTH, None:
|
||||
app.append_context(tenant=context['tenant'])
|
||||
case AuthFlowType.USER_AUTH, str():
|
||||
print(tenant)
|
||||
|
||||
return next_middleware(app)
|
||||
|
||||
|
||||
@@ -108,7 +116,8 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
|
||||
ip_addr = req_context.http.source_ip
|
||||
response = next_middleware(app)
|
||||
|
||||
# Successful request
|
||||
# Successful response
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status#successful_responses
|
||||
if 200 <= response.status_code < 300 and user:
|
||||
now_ = now()
|
||||
data = (
|
||||
@@ -124,7 +133,8 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
|
||||
|
||||
self.collect.put_item(
|
||||
key=KeyPair(
|
||||
pk=ComposeKey(user.id, prefix='logs'),
|
||||
# Post-migration: remove `delimiter` from ComposeKey.
|
||||
pk=ComposeKey(user.id, prefix='logs', delimiter=':'),
|
||||
sk=now_.isoformat(),
|
||||
),
|
||||
action=self.action,
|
||||
|
||||
Reference in New Issue
Block a user