aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db/migrations/versions')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a9b8c7d6e5f4_add_login_throttle.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a9b8c7d6e5f4_add_login_throttle.py b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a9b8c7d6e5f4_add_login_throttle.py
new file mode 100644
index 0000000..2fead6c
--- /dev/null
+++ b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/a9b8c7d6e5f4_add_login_throttle.py
@@ -0,0 +1,33 @@
+"""add login_throttle
+
+Wrong passphrases per username, for the per-account sign-in lockout. Keyed by a
+hash of the name as typed, so unknown names are counted like real ones.
+
+Revision ID: a9b8c7d6e5f4
+Revises: e5f6a7b8c9d0
+"""
+
+from typing import Sequence, Union
+
+import sqlalchemy as sa
+from alembic import op
+
+revision: str = "a9b8c7d6e5f4"
+down_revision: Union[str, Sequence[str], None] = "e5f6a7b8c9d0"
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+
+def upgrade() -> None:
+ op.create_table(
+ "login_throttle",
+ sa.Column("key", sa.String(64), primary_key=True),
+ sa.Column("failures", sa.Integer(), nullable=False, server_default="0"),
+ sa.Column("last_failure_at", sa.DateTime(timezone=True), nullable=False),
+ )
+
+
+def downgrade() -> None:
+ # Dropping this forgets every count in progress, which unlocks everyone —
+ # the limits themselves live in `hub_settings`.
+ op.drop_table("login_throttle")