Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
- Add jira_api_token field to User model + migration b042 - Per-user Jira client: user's corporate email + personal Atlassian token - Admin-configurable Jira URL/project via system_configs (GET/PATCH /system/jira-config + POST /system/jira-test) - Auto-create Jira ticket when a test is created (non-fatal) - Push lifecycle comments on every state transition: draft→red_executing→blue_evaluating→in_review→validated/rejected→draft - Rich ticket descriptions with technique, MITRE ID, priority from severity, labels - UserOut.jira_token_set (bool) instead of exposing raw token - PATCH /users/me/preferences now accepts jira_api_token Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
import uuid
|
|
from sqlalchemy import Column, String, Boolean, DateTime, func
|
|
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class User(Base):
|
|
"""
|
|
User model for authentication and authorization.
|
|
|
|
Possible roles:
|
|
- admin: Full system access
|
|
- red_tech: Red team technician - can create and edit tests
|
|
- blue_tech: Blue team technician - can create and edit tests
|
|
- red_lead: Red team lead - can validate tests
|
|
- blue_lead: Blue team lead - can validate tests
|
|
- viewer: Read-only access (default)
|
|
"""
|
|
__tablename__ = "users"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
username = Column(String, unique=True, nullable=False)
|
|
email = Column(String, nullable=True)
|
|
hashed_password = Column(String, nullable=False)
|
|
role = Column(String, nullable=False, default="viewer")
|
|
is_active = Column(Boolean, default=True)
|
|
must_change_password = Column(Boolean, default=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
last_login = Column(DateTime, nullable=True)
|
|
notification_preferences = Column(JSONB, nullable=True, server_default='{"email_on_test_validated": true, "email_on_campaign_completed": true, "email_on_new_mitre_techniques": false, "in_app_all": true}')
|
|
jira_account_id = Column(String(100), nullable=True)
|
|
jira_api_token = Column(String(500), nullable=True) # personal Atlassian token
|