Safe outbound HTTP and remote actors (phase 2, step 2)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 1m22s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 1m22s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
- net.py: the only client federation uses, on httpcore (BSD-3-Clause) with a guarded network backend: https only, every resolved address must be public (private, loopback, link-local, CGNAT, multicast and IPv4-mapped forms refused), and the connection goes to the checked address; 3 redirects max (GET only), 1 MB cap, 10s/20s timeouts - outbound.py: signed GETs (instance actor, so authorized-fetch servers answer) and signed POSTs (as the user), trying the configured signature schemes in order and the next only on a 401 - remote.py + federation_remote_actors: fetch, validate (id matches URL and host, actor type, inbox on its host, key owned by the actor), cache for 24h, refresh on demand, 410 marks an actor gone; resolve a key id to its actor, including standalone key documents - Config: FEDERATION_SIGNATURE_SCHEMES, FEDERATION_BLOCKED_DOMAINS, FEDERATION_DELIVERY_CONCURRENCY, and FEDERATION_INSECURE_TESTING (http and private addresses; only allowed for .test domains) - Tests against a real local HTTP server, including verifying that our fetches carry a valid signature Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
a6d3fb6c93
commit
52b9f0b27b
10 files changed
+823
-3
No files matched your search
@@ -46,3 +46,29 @@ class FederationKey(db.Model):
|
||||
public_key_pem: Mapped[str] = mapped_column(Text)
|
||||
private_key_encrypted: Mapped[bytes] = mapped_column(LargeBinary)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
|
||||
|
||||
class FederationRemoteActor(db.Model):
|
||||
"""A cached copy of another server's actor (who follows us, and their key)."""
|
||||
|
||||
__tablename__ = "federation_remote_actors"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
uri: Mapped[str] = mapped_column(String(2048), unique=True)
|
||||
host: Mapped[str] = mapped_column(String(255), index=True)
|
||||
inbox: Mapped[str] = mapped_column(String(2048))
|
||||
shared_inbox: Mapped[str | None] = mapped_column(String(2048))
|
||||
username: Mapped[str | None] = mapped_column(String(255)) # preferredUsername
|
||||
display_name: Mapped[str | None] = mapped_column(String(255))
|
||||
public_key_id: Mapped[str] = mapped_column(String(2048), index=True)
|
||||
public_key_pem: Mapped[str] = mapped_column(Text)
|
||||
fetched_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
gone: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
|
||||
@property
|
||||
def handle(self) -> str:
|
||||
return f"@{self.username or '?'}@{self.host}"
|
||||
|
||||
@property
|
||||
def delivery_inbox(self) -> str:
|
||||
return self.shared_inbox or self.inbox
|
||||
Reference in new issue
Block a user