Merge pull request #1179 from PR0M3TH3AN/codex/update-access-control-logic-and-documentation

Enforce blacklist precedence over whitelist in access control
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-11 09:19:09 -05:00
commit d1fdb5388c
2 files changed
+13 -23

No files matched your search

+2 -2
View File
@@ -6,7 +6,7 @@ bitvid is follow-centric. Your Home feed comes from people you follow (F1). Disc
## Core principles
- **Freedom to choose**: User picks filters. Defaults are safe but reversible.
- **Explain decisions**: Every blur/hide shows a “why” badge and a “show anyway” control.
- **Whitelist > blacklist**: Prefer showing content from trusted networks over fighting global spam.
- **Blacklist > whitelist**: Admin blacklists and moderation gates always win; whitelists only influence Discovery ranking.
- **Minimal central power**: Admin lists are opt-in; users can unsubscribe.
## Threat model (short)
@@ -67,7 +67,7 @@ Operators can delegate hard-hide decisions to trusted curators without giving th
1. The super admin maintains a `kind 30000` list with `d=${ADMIN_LIST_NAMESPACE}:${ADMIN_COMMUNITY_BLACKLIST_SOURCES}`. Each `a` tag references a community curator’s blacklist as `30000:<curator hex pubkey>:${ADMIN_LIST_NAMESPACE}:${ADMIN_COMMUNITY_BLACKLIST_PREFIX}:<slug>`.
2. Every curator publishes their own `kind 30000` list using the referenced `d` tag (`${ADMIN_LIST_NAMESPACE}:${ADMIN_COMMUNITY_BLACKLIST_PREFIX}:<slug>`) and fills it with `p` tags for accounts they want hidden.
3. bitvid automatically fetches each referenced list, merges the entries into the global blacklist, and removes any duplicates or guard-protected accounts (super admin, editors, or whitelist members).
3. bitvid automatically fetches each referenced list, merges the entries into the global blacklist, and removes any duplicates or guard-protected accounts (super admin or editors).
To add a community list, append a new `a` tag to the super-admin source list and ask the curator to publish their companion `p` list. To remove a list, delete the `a` tag or ask the curator to clear their `p` entries; the client stops ingesting it on the next refresh.
+11 -21
View File
@@ -265,7 +265,6 @@ class AccessControl {
const whitelistChanged = !areSetsEqual(previousWhitelist, this.whitelist);
const blacklistDedupe = dedupeNpubs(blacklist);
const whitelistSet = new Set(normalizedWhitelist.map(normalizeNpub));
const adminGuardSet = new Set([
normalizeNpub(ADMIN_SUPER_NPUB),
...Array.from(this.editors),
@@ -275,9 +274,6 @@ class AccessControl {
if (!normalized) {
return false;
}
if (whitelistSet.has(normalized)) {
return false;
}
if (adminGuardSet.has(normalized)) {
return false;
}
@@ -698,15 +694,9 @@ class AccessControl {
if (!normalized) {
return false;
}
if (this.whitelist.has(normalized)) {
return false;
}
const normalizedHexCandidate = normalizeHexKey(normalized);
if (normalizedHexCandidate) {
if (this.whitelistPubkeys.has(normalizedHexCandidate)) {
return false;
}
return this.blacklistPubkeys.has(normalizedHexCandidate);
}
@@ -754,14 +744,14 @@ class AccessControl {
return false;
}
if (this.whitelistPubkeys.has(hex)) {
return true;
}
if (this.blacklistPubkeys.has(hex)) {
return false;
}
if (this.whitelistPubkeys.has(hex)) {
return true;
}
if (this.whitelistEnabled && !this.whitelistPubkeys.has(hex)) {
return false;
}
@@ -778,22 +768,22 @@ class AccessControl {
}
if (hex) {
if (this.whitelistPubkeys.has(hex)) {
return true;
}
if (this.blacklistPubkeys.has(hex)) {
return false;
}
}
if (this.whitelist.has(normalized)) {
return true;
if (this.whitelistPubkeys.has(hex)) {
return true;
}
}
if (this.blacklist.has(normalized)) {
return false;
}
if (this.whitelist.has(normalized)) {
return true;
}
if (this.whitelistEnabled && !this.whitelist.has(normalized)) {
return false;
}