Federation data and actor keys (phase 1, step 1)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 57s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s

- federation_settings (per user; off, followers-only, not discoverable
  by default) and federation_keys (RSA-2048; NULL user = instance
  actor), on the federation migration branch
- Private keys encrypted at rest with Fernet, keyed by HKDF-SHA256 from
  FEDERATION_KEY_SECRET (now required, 32+ chars, never printed)
- Keys are created when a user first enables sharing and never
  regenerated; sharing.shared_user() treats unknown and non-sharing
  users identically
- One flask-smorest Api per app (get_api(app)), so apps with and
  without federation never share an OpenAPI spec
- Test fixtures for a second, federation-enabled app on the same DB

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 20:19:14 +01:00
1 parent 00ad8e9e6d
commit 98c65547f3
12 files changed
+513 -5

No files matched your search

@@ -0,0 +1,52 @@
"""federation settings and keys
Revision ID: 34508576a6c7
Revises: federation_0001
Create Date: 2026-09-25 20:18:10.573299
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '34508576a6c7'
down_revision = 'federation_0001'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('federation_keys',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('public_key_pem', sa.Text(), nullable=False),
sa.Column('private_key_encrypted', sa.LargeBinary(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id')
)
op.create_table('federation_settings',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('enabled', sa.Boolean(), nullable=False),
sa.Column('visibility', sa.String(length=16), nullable=False),
sa.Column('manually_approves_followers', sa.Boolean(), nullable=False),
sa.Column('discoverable', sa.Boolean(), nullable=False),
sa.Column('indexable', sa.Boolean(), nullable=False),
sa.Column('display_name', sa.String(length=100), nullable=True),
sa.Column('bio', sa.Text(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('user_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('federation_settings')
op.drop_table('federation_keys')
# ### end Alembic commands ###