Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
- Add must_change_password field to User model with migration b023 - Add POST /auth/change-password endpoint with password policy validation - Add require_password_changed dependency to block requests until password is changed - Add ChangePasswordModal with live password policy checklist (forced on first login) - Show password policy in CreateUserModal and EditUserModal - Fix backend permissions: tests, campaigns, templates, reports, evidence, worklogs - red_tech/blue_tech: execute only, cannot create tests/campaigns/templates - red_lead/blue_lead: create/edit tests/campaigns/templates, generate reports, no system access - viewer: read-only everywhere, can generate reports - Fix frontend role checks across TestDetailPage, TestDetailHeader, TeamTabs, TestsPage, CampaignsPage, CampaignDetailPage, Sidebar
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import Column, String, Boolean, DateTime
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
|
|
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, default=datetime.utcnow)
|
|
last_login = Column(DateTime, nullable=True)
|