add reset password

This commit is contained in:
2025-04-14 10:49:28 -03:00
parent 273c580139
commit e472826dcc
17 changed files with 228 additions and 56 deletions

View File

@@ -1,9 +1,9 @@
from .audit_log_middleware import AuditLogMiddleware
from .authorizer_middleware import AuthorizerMiddleware, User
from .authentication_middleware import AuthenticationMiddleware, User
from .tenant_middelware import Tenant, TenantMiddleware
__all__ = [
'AuthorizerMiddleware',
'AuthenticationMiddleware',
'AuditLogMiddleware',
'TenantMiddleware',
'User',

View File

@@ -17,7 +17,7 @@ from layercake.dynamodb import (
)
from layercake.funcs import pick
from .authorizer_middleware import User
from .authentication_middleware import User
YEAR_DAYS = 365
LOG_RETENTION_DAYS = YEAR_DAYS * 2
@@ -29,14 +29,14 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
Parameters
----------
action : str
action: str
The identifier for the audit log action.
collect : DynamoDBCollection
collect: DynamoDBCollection
The collection instance used to persist the audit log data.
audit_attrs : tuple of str, optional
audit_attrs: tuple of str, optional
A tuple of attribute names to extract from the response body for logging.
These represent the specific fields to include in the audit log.
retention_days : int or None, optional
retention_days: int or None, optional
The number of days the log is retained on the server.
If None, no time-to-live (TTL) will be applied.
"""
@@ -64,10 +64,13 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
ip_addr = req_context.http.source_ip
response = next_middleware(app)
print(app.context['_route'])
# 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()
author = pick(('id', 'name'), dict(user))
data = (
pick(self.audit_attrs, extract_event_from_common_models(response.body))
if response.is_json()
@@ -89,7 +92,7 @@ class AuditLogMiddleware(BaseMiddlewareHandler):
action=self.action,
data=data,
ip=ip_addr,
author='himself',
author=author,
ttl=retention_days,
)

View File

@@ -23,7 +23,7 @@ class CognitoUser(User):
sub: UUID4
class AuthorizerMiddleware(BaseMiddlewareHandler):
class AuthenticationMiddleware(BaseMiddlewareHandler):
"""This middleware extracts user authentication details from the Lambda authorizer context
and makes them available in the application context."""

View File

@@ -18,7 +18,7 @@ from pydantic import UUID4, BaseModel
from auth import AuthFlowType
from .authorizer_middleware import User
from .authentication_middleware import User
class Tenant(BaseModel):