gabriel / musehub public
0007_ed25519_auth_keys.py python
48 lines 1.6 KB
Raw
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a init: musehub initial commit Human 171 days ago
1 """Add musehub_auth_keys table for Ed25519 public-key authentication.
2
3 Each row is one registered Ed25519 public key that may authenticate as a
4 MuseHub identity. The challenge-response flow is stateless (nonces are
5 short-lived hex tokens); only the long-lived public key registration lives here.
6
7 Revision ID: 0007
8 Revises: 0006
9 """
10 from __future__ import annotations
11
12 import sqlalchemy as sa
13 from alembic import op
14
15 revision = "0007"
16 down_revision = "0006"
17 branch_labels = None
18 depends_on = None
19
20
21 def upgrade() -> None:
22 op.create_table(
23 "musehub_auth_keys",
24 sa.Column("key_id", sa.String(36), primary_key=True),
25 sa.Column(
26 "identity_id",
27 sa.String(36),
28 sa.ForeignKey("musehub_identities.id", ondelete="CASCADE"),
29 nullable=False,
30 ),
31 sa.Column("public_key_b64", sa.String(64), nullable=False),
32 sa.Column("fingerprint", sa.String(64), nullable=False),
33 sa.Column("label", sa.String(255), nullable=False, server_default=""),
34 sa.Column(
35 "created_at",
36 sa.DateTime(timezone=True),
37 nullable=False,
38 server_default=sa.func.now(),
39 ),
40 sa.Column("last_used_at", sa.DateTime(timezone=True), nullable=True),
41 sa.UniqueConstraint("fingerprint", name="uq_musehub_auth_keys_fingerprint"),
42 )
43 op.create_index("ix_musehub_auth_keys_identity_id", "musehub_auth_keys", ["identity_id"])
44
45
46 def downgrade() -> None:
47 op.drop_index("ix_musehub_auth_keys_identity_id", table_name="musehub_auth_keys")
48 op.drop_table("musehub_auth_keys")
File History 1 commit
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a init: musehub initial commit Human 171 days ago