6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
"""One-shot cutover helper to revoke every refresh token.
|
|
|
|
Run with --yes during the auth-hardening cutover, alongside setting
|
|
MIN_ISSUED_AT to the deploy epoch.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import asyncio
|
|
|
|
from sqlalchemy import text
|
|
|
|
from app.db import async_session_maker
|
|
|
|
|
|
async def _count_active_tokens() -> int:
|
|
async with async_session_maker() as session:
|
|
result = await session.execute(
|
|
text(
|
|
"""
|
|
SELECT count(*)
|
|
FROM refresh_tokens
|
|
WHERE revoked_at IS NULL
|
|
AND expires_at > NOW()
|
|
"""
|
|
)
|
|
)
|
|
return int(result.scalar_one())
|
|
|
|
|
|
async def _revoke_all_tokens() -> int:
|
|
async with async_session_maker() as session:
|
|
result = await session.execute(
|
|
text(
|
|
"""
|
|
UPDATE refresh_tokens
|
|
SET revoked_at = NOW(),
|
|
expires_at = NOW()
|
|
WHERE revoked_at IS NULL
|
|
OR expires_at > NOW()
|
|
"""
|
|
)
|
|
)
|
|
await session.commit()
|
|
return int(result.rowcount or 0)
|
|
|
|
|
|
async def main() -> None:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
"--yes",
|
|
action="store_true",
|
|
help="Actually revoke tokens. Without this flag the command is a dry run.",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
active_count = await _count_active_tokens()
|
|
if not args.yes:
|
|
print(f"Dry run: {active_count} active refresh token(s) would be revoked.")
|
|
print("Re-run with --yes during the auth-hardening cutover to revoke them.")
|
|
return
|
|
|
|
updated_count = await _revoke_all_tokens()
|
|
print(f"Revoked {updated_count} refresh token row(s).")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|