Skip to content

refactor(security)!: decouple access control #279

Closed

Description

@uniqueg

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_specs or self_service without enabled; enabled without auth.issuers (from PR 1).
  • Update the model docstrings, template and examples (petstore-access-control sets enabled: true).

Acceptance criteria

  • Default config: no access-control DB, adapter or /permissions routes (test via app.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.

Related

Simp #10; Sec #1 (issuers); #157

Activity

  1. added
    priority: high
    type flag: breaking change
    type: auth
    type: maintenance
    workload: hours
    on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: hightype flag: breaking changetype: authtype: maintenanceworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions