fix: merge main, address code review feedback for security fix PR #816
- Merge origin/main into branch (resolve conflict in integrations_dashboard.html) - Add defensive JSON parsing with try/except for integration.config - Wrap tester() call in try/except to prevent 500 errors from bad config - Add i18n key integrations.connection_test_failed_fallback in en.json - Reference i18n key in template JS fallback message - Update SECURITY_AUDIT.md: add fix date (2026-03-23), update doc date - Remove accidental revert.sh file - Fix missing MagicMock/patch imports in test file - Add tests for invalid JSON config and tester exception error paths Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/daebb70e-059a-4601-8864-88eef49f99cf
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
"""Add expires_at column to api_tokens table.
|
||||
|
||||
Allows API tokens to be issued with an optional lifetime. If ``expires_at``
|
||||
is set, the token is automatically rejected after that timestamp.
|
||||
|
||||
Revision ID: 038_add_api_token_expires_at
|
||||
Revises: 037_add_user_sessions_and_qr_challenges
|
||||
Create Date: 2026-03-18
|
||||
"""
|
||||
|
||||
from typing import Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "038_add_api_token_expires_at"
|
||||
down_revision: Union[str, None] = "037_add_user_sessions_and_qr_challenges"
|
||||
depends_on: Union[str, None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Add expires_at column to api_tokens (idempotent)."""
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
if "api_tokens" not in inspector.get_table_names():
|
||||
return
|
||||
existing_columns = {col["name"] for col in inspector.get_columns("api_tokens")}
|
||||
if "expires_at" not in existing_columns:
|
||||
op.add_column(
|
||||
"api_tokens",
|
||||
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Remove expires_at column from api_tokens."""
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
if "api_tokens" not in inspector.get_table_names():
|
||||
return
|
||||
existing_columns = {col["name"] for col in inspector.get_columns("api_tokens")}
|
||||
if "expires_at" in existing_columns:
|
||||
op.drop_column("api_tokens", "expires_at")
|
||||
Reference in New Issue
Block a user