Repository navigation
Description
Problem
A. Mixed rule sets during reconciliation. At startup, every app instance reconciles the configured policies (security.access_control.policies) into the shared policy collection, rule by rule and without a transaction (foca/security/access_control/register_access_control.py, Adapter.set_configured_policies()). Requests are enforced against whatever the collection holds at that moment. So during a rolling update that changes the policies, or after a database error midway, requests can be authorized against a mix of old and new rules. Sourcery raised this on PR #409; it was declined there to keep that PR focused.
B. Configured rules outlive their removal. An overlay can add a named policy even if the base config has none. Removing it later does not work:
- Setting it to
nullfails, as named entries can only remove entries the base config has. - Deleting the overlay line leaves
policiesunset (defaultNone,foca/models/config.py), so no reconciliation runs.
The rule stays stored with configured: True. It keeps granting access, and the permissions API answers 409 Conflict to deleting it. Reproduced on MongoDB 7.0.
Expected
- Requests see either the previous complete set of configured rules or the new one, never a mix.
- No transactions: FOCA supports standalone MongoDB servers.
- Stored configured rules do not outlive their removal from the config.
Suggested design: store the new set under a new generation ID, switch a single marker document to it in one write, then delete the old generation. Enforcement loads only the active generation, plus the rules that are not configured.
For B, either (i) warn at startup about stale configured rules and tell the operator to set policies: {} or [], or (ii) manage stored configured rules whenever any exist, so that an unset policies removes them. (ii) is preferred if it is safe and simple. Apps that never configure policies and data from 0.16.0 must keep working. The choice is documented.
Activity
uniqueg commentedon Oct 23, 2026
Done in #423.