···
// We cannot allow arbitrary domains to prevent impersonation attacks
// Example attack: !leagueoflegends@riotgames.com on a non-Riot instance
151
-
// TODO (Security - V2.1): Implement did:web domain verification
152
-
// Currently, any self-hoster can set INSTANCE_DID=did:web:nintendo.com without
153
-
// actually owning nintendo.com. This allows domain impersonation attacks.
154
-
// Solution: Verify domain ownership by fetching https://domain/.well-known/did.json
155
-
// and ensuring it matches the claimed DID. See: https://atproto.com/specs/did-web
156
-
// Alternatively, switch to did:plc for instance DIDs (cryptographically unique).
151
+
// SECURITY: did:web domain verification is implemented in the Jetstream consumer
152
+
// See: internal/atproto/jetstream/community_consumer.go - verifyHostedByClaim()
153
+
// Communities with mismatched hostedBy domains are rejected during indexing
var instanceDomain string
if strings.HasPrefix(instanceDID, "did:web:") {
// Extract domain from did:web (this is the authoritative source)
···
communityJetstreamURL = "ws://localhost:6008/subscribe?wantedCollections=social.coves.community.profile&wantedCollections=social.coves.community.subscription"
232
-
communityEventConsumer := jetstream.NewCommunityEventConsumer(communityRepo)
229
+
// Initialize community event consumer with did:web verification
230
+
skipDIDWebVerification := os.Getenv("SKIP_DID_WEB_VERIFICATION") == "true"
231
+
if skipDIDWebVerification {
232
+
log.Println("⚠️ WARNING: did:web domain verification is DISABLED (dev mode)")
233
+
log.Println(" Set SKIP_DID_WEB_VERIFICATION=false for production")
236
+
communityEventConsumer := jetstream.NewCommunityEventConsumer(communityRepo, instanceDID, skipDIDWebVerification)
communityJetstreamConnector := jetstream.NewCommunityJetstreamConnector(communityEventConsumer, communityJetstreamURL)