Repository navigation
Description
A ledger configured f:defaultAllow false still serves every row to an anonymous reader, and the read and write paths disagree about it in a way I think is worth fixing — or at minimum documenting clearly, because the disagreement produces a false "my config is working" signal.
I want to frame this as a design question rather than a bug report. The current behavior is deliberate at each individual gate; it's the combination that surprises.
What happens
On a ledger whose config graph declares f:defaultAllow false, with a request carrying no identity, no policy-class, and no inline policy (verified over HTTP against /v1/fluree/query and /v1/fluree/insert):
| Ledger config | Anonymous read | Anonymous write |
|---|---|---|
f:defaultAllow false alone |
returns every row | succeeds (200) |
f:defaultAllow false + f:policyClass |
returns every row | denied (400, "Policy enforcement prevents modification.") |
The second row is the uncomfortable one. An operator who configures both — which is the shape our own docs use in their examples — gets a loud, clearly-correct denial on writes, and no enforcement whatsoever on reads. Writes being denied is exactly the positive control someone would use to convince themselves the config took effect.
Mechanism
The two paths consult config in the opposite order relative to their enforcement gate.
Reads gate before merging. apply_source_or_global_policy (fluree-db-api/src/query/connection.rs:1080) calls wrap_policy only when global_opts.has_any_policy_inputs() is true, and that's the raw request opts — merge_policy_opts, which folds in the ledger's f:defaultAllow / f:policyClass, runs inside wrap_policy (fluree-db-api/src/view/fluree_ext.rs:707). So for a request with no policy inputs the config is never consulted and no PolicyContext is built at all. Not "a context with default-allow true" — no policy object.
Writes merge before gating. build_transact_policy_context merges config first (fluree-db-api/src/policy_view.rs:369) and only then checks effective_opts.has_any_policy_inputs() (:439). A config-supplied f:policyClass lands in the merged opts and flips that predicate, so a context gets built and f:defaultAllow false governs — hence the 400.
That also explains why f:defaultAllow false alone doesn't lock writes: it merges in, but a bare default-deny isn't itself treated as a request for enforcement, so the predicate stays false and the transaction runs unrestricted.
Current read behavior is pinned in anonymous_request_unenforced_despite_config_default_allow_false (fluree-db-api/tests/it_config_graph.rs).
Why this is more pointed after #1625
#1625 makes GovernanceOptions.default_allow tri-state so a configured f:defaultAllow true actually reaches identity-carrying requests (previously merely supplying an identity read as an implicit override back to deny). After it lands, f:defaultAllow can open a ledger but still can't close one:
| Ledger config | Anonymous | Identity-carrying |
|---|---|---|
f:defaultAllow true |
sees everything | sees everything (fixed by #1625) |
f:defaultAllow false |
sees everything | sees only schema triples |
Half of the setting starts behaving the way operators expect, which makes it more reasonable — not less — to assume the other half does too.
Docs currently promise the opposite
docs/ledger-config/setting-groups.md:41 says config-declared f:policyClass / f:defaultAllow defaults "apply to transactions even when the request itself carries no policy inputs." For transactions with a configured f:policyClass that's true; for reads it isn't, and the sentence reads as a general guarantee.
Relatedly, setting-groups.md:13 and :20 give the Policy system default as f:defaultAllow true and call an unconfigured ledger "fully open," while docs/security/policy-model.md:246 documents default-allow: false as fail-closed and recommended for production. Both are defensible depending on whether a request carries an identity, but stated flatly they contradict each other.
Open questions
-
Should
f:defaultAllow falseengage enforcement for an otherwise-anonymous request? The operator-intent reading says yes — the config is the ledger's own posture, and a request shouldn't escape it by saying nothing. The cost is that any existing ledger carrying a config withf:defaultAllow falsewould flip from fully-open to schema-only for anonymous reads with no client change. That's the fix working as intended, but it needs a prominent release note. -
If yes, what should "enforced anonymous" mean? With the existing
is_rootcomputation (fluree-db-api/src/policy_builder.rs:465-471), a non-root context with an empty restriction set anddefault_allow: falsedenies every non-schema flake, so the caller sees ontology triples and nothing else (schema flakes bypass policy unconditionally —fluree-db-policy/src/schema.rs:72-80). Is "200 with schema only" right, or should an unauthenticated request against a closed ledger be refused outright? I lean toward the former, for consistency with how a fully-denied identity is already treated, but it should be a deliberate choice. -
Should the read and write paths be reconciled regardless of how 1 lands? Even leaving anonymous reads open, having one path gate on pre-merge opts and the other on post-merge opts is the kind of divergence that produces exactly this class of surprise. Making the gate order consistent may be worth doing on its own.
-
Where does the decision live? Today the gate is a pure function of the request. Letting config participate means the decision to build a context — not merely its default — has to consult resolved config, which is a different shape from
merge_policy_optsfilling defaults in afterwards. There's alsoOverrideControlto think about, and whether server-level config should participate the same way. -
How would a deployment that wants "anonymous reads allowed, identities enforced" express that once
falsemeans locked? Presumably a policy granting to everyone — but I'd want to confirm there's a real spelling for that and document it. If there isn't, the design has a hole.
Happy to take the implementation once 1–3 are settled; the tri-state plumbing from #1625 is the natural foundation.
Activity
bplatz commentedon Sep 26, 2026
Resolved by #1804 (merged 2026-09-11, commits 61cadaf / b2542da), which didn't reference this issue.
Reads: a request with no policy inputs now routes through
wrap_policy_defaults, which applies the ledger'sf:defaultAllow/f:policyClasswhenever the config graph declares a policy group. Connection, dataset, SPARQL, stream, Bolt and GraphQL reads all take it. Unconfigured ledgers remain open.Writes:
has_any_policy_inputs()now countsdefault_allow == Some(false), so a merged-inf:defaultAllow falsealone engages enforcement on an anonymous write.f:policyClassis no longer needed alongside it. Read and write both merge config before gating.How the open questions landed:
The old pin was flipped to
anonymous_request_enforces_config_default_allow_false(fluree-db-api/tests/it_config_graph.rs), which passes. The write side was checked by callingbuild_transact_policy_context(what the consensus write path calls every transaction) with empty governance. It returns a non-root context for af:defaultAllow falseledger and none for an unconfigured one.Residue, not blocking closure:
docs/ledger-config/setting-groups.md:22and:39still describe the old behaviour. To be folded into a later docs pass.graph_query_builder.rs:176), which also doesn't apply defaults. Adjacent to graph-scoped query builder ignores opts.policy for native ledgers #1766.f:defaultAllow falseledgers (anonymous reads went from fully open to schema-only). Worth a release-note line if Add trusted policy delegation across SDK and server interfaces #1804's notes didn't cover it.