| 1234567891011121314151617 |
- from datetime import datetime
- from core_db import AuditMixin, Base, EntityMixin
- from sqlalchemy import DateTime, String, Text
- from sqlalchemy.orm import Mapped, mapped_column
- class ApiKey(EntityMixin, AuditMixin, Base):
- __tablename__ = "auth_api_key"
- name: Mapped[str] = mapped_column(String(128))
- key_prefix: Mapped[str] = mapped_column(String(16), index=True)
- key_hash: Mapped[str] = mapped_column(String(128), unique=True, index=True)
- scopes: Mapped[str | None] = mapped_column(Text, nullable=True)
- expires_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
- last_used_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
- revoked_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, index=True)
|