feat(demo): demo-account schema + reusable rate limiter
Add the shared demo-account plumbing: users.is_demo marks the single shared demo user, demo_whitelist holds the admin-curated emails that may enter it without Google sign-in, and a small in-process RateLimiter (generic groundwork) for throttling the demo-login endpoint per IP.
This commit is contained in:
parent
af84cc0404
commit
9cac2cd335
3 changed files with 124 additions and 0 deletions
59
backend/alembic/versions/0014_demo_account.py
Normal file
59
backend/alembic/versions/0014_demo_account.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
"""demo account: users.is_demo + demo_whitelist
|
||||
|
||||
Revision ID: 0014_demo_account
|
||||
Revises: 0013_playlist_fingerprint
|
||||
Create Date: 2026-06-16
|
||||
|
||||
Adds the shared demo-account plumbing:
|
||||
- users.is_demo — marks the single shared demo user (no OAuth token / YouTube scope).
|
||||
- demo_whitelist — admin-curated emails that may enter the demo account from the login
|
||||
page without Google sign-in. Multiple emails are just keys to the same shared door.
|
||||
The demo user row itself is created lazily on first demo login (works across all three DBs
|
||||
without a data migration), so this only adds the schema.
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0014_demo_account"
|
||||
down_revision: Union[str, None] = "0013_playlist_fingerprint"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"users",
|
||||
sa.Column(
|
||||
"is_demo",
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default=sa.false(),
|
||||
),
|
||||
)
|
||||
op.create_index("ix_users_is_demo", "users", ["is_demo"])
|
||||
|
||||
op.create_table(
|
||||
"demo_whitelist",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column("email", sa.String(length=320), nullable=False),
|
||||
sa.Column("note", sa.Text(), nullable=True),
|
||||
sa.Column("added_by", sa.String(length=320), nullable=True),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.func.now(),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
"ix_demo_whitelist_email", "demo_whitelist", ["email"], unique=True
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("ix_demo_whitelist_email", table_name="demo_whitelist")
|
||||
op.drop_table("demo_whitelist")
|
||||
op.drop_index("ix_users_is_demo", table_name="users")
|
||||
op.drop_column("users", "is_demo")
|
||||
Loading…
Add table
Add a link
Reference in a new issue