feat(phases): implement webhooks (6.1), email (7.1), user preferences (7.2)
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
- Phase 6.1: WebhookConfig model, CRUD router (/api/v1/webhooks, admin-only), dispatch_webhook() with HMAC signing; integrated into test validation, campaign completion, and MITRE sync job - Phase 7.1: SMTP email service with send_test_validated_email, send_campaign_completed_email, send_new_mitre_techniques_email; notify_role_with_email() added to notification_service - Phase 7.2: notification_preferences and jira_account_id on User model; PATCH /users/me/preferences endpoint; Alembic migrations b031phase6 and b032phase7 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -121,6 +121,13 @@ class PasswordChange(BaseModel):
|
||||
return _validate_password_strength(v)
|
||||
|
||||
|
||||
class UserPreferencesUpdate(BaseModel):
|
||||
"""Payload for updating current user's notification preferences and Jira account."""
|
||||
|
||||
notification_preferences: dict | None = None
|
||||
jira_account_id: str | None = None
|
||||
|
||||
|
||||
class UserOut(BaseModel):
|
||||
"""Complete representation returned by the API."""
|
||||
|
||||
@@ -132,5 +139,7 @@ class UserOut(BaseModel):
|
||||
must_change_password: bool = True
|
||||
created_at: datetime | None = None
|
||||
last_login: datetime | None = None
|
||||
notification_preferences: dict | None = None
|
||||
jira_account_id: str | None = None
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
32
backend/app/schemas/webhook.py
Normal file
32
backend/app/schemas/webhook.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""Pydantic schemas for Webhook endpoints."""
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
from pydantic import BaseModel, HttpUrl, ConfigDict
|
||||
|
||||
class WebhookConfigCreate(BaseModel):
|
||||
name: str
|
||||
url: str
|
||||
secret: str | None = None
|
||||
events: list[str] = []
|
||||
is_active: bool = True
|
||||
|
||||
class WebhookConfigUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
url: str | None = None
|
||||
secret: str | None = None
|
||||
events: list[str] | None = None
|
||||
is_active: bool | None = None
|
||||
|
||||
class WebhookConfigOut(BaseModel):
|
||||
id: uuid.UUID
|
||||
name: str
|
||||
url: str
|
||||
secret: str | None = None # masked on read
|
||||
events: list[str]
|
||||
is_active: bool
|
||||
created_by: uuid.UUID | None = None
|
||||
last_triggered_at: datetime | None = None
|
||||
failure_count: int
|
||||
created_at: datetime | None = None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
Reference in New Issue
Block a user