Repository navigation
Description
Problem
security.auth.required (default True) does not enforce authentication; per-operation security in the specs does that. Its only use is in Foca.create_app (foca/foca.py), where it decides whether to register the access-control database, the Casbin adapter (its own MongoClient) and the permissions API. Every app with default settings, including the plain examples/petstore, therefore mounts an admin API and connects to access_control_db. An inconsistent config (access-control options set without auth) only logs an error, and SecurityConfig.validate_enforce_access_control ties enforce to auth.required.
Proposal
- Add
security.access_control.enabled: bool = False. Only when it is true does FOCA register the policy collection, adapter and permissions API. - Remove
security.auth.required. - Validation errors instead of log messages:
enforce,api_specsorself_servicewithoutenabled;enabledwithoutauth.issuers(from PR 1). - Update the model docstrings, template and examples (
petstore-access-controlsetsenabled: true).
Acceptance criteria
- Default config: no access-control DB, adapter or
/permissionsroutes (test viaapp.url_map/client). -
enabled: true: all three are registered (test). - Each inconsistent combination raises
ValidationError(tests). - Docs explain that authentication is configured per operation in the spec and access control via
enabled.
Breaking changes
Remove security.auth.required from configs. Apps that use the permissions API or enforce must set security.access_control.enabled: true. Apps that do not use access control no longer get an access_control_db.
Activity