Skip to content

refactor(access-control): tidy permissions API #278

Closed

Description

@uniqueg

Problem

In foca/security/access_control/access_control_server.py:

  • The same collection lookup through current_app.config.foca.db.dbs[...] is copied four times (with type: ignores).
  • putPermission writes to the collection directly, bypassing the Adapter used by postPermission, so the two endpoints store differently shaped documents.
  • getAllPermissions/getPermission del ptype and id unconditionally; one stored rule without id makes the list endpoint fail with 500.
  • except Exception turns everything, including bad requests, into 500 and logs a second time.

In foca_casbin_adapter/: CasbinRule.dict() scans dir(self); CasbinRule.__repr__ calls print(); load_policy is typed with CasbinRule instead of casbin.model.Model; an assert validates the collection; save_policy appends instead of replacing, which creates duplicates.

Proposal

Acceptance criteria

  • post and put store identically shaped documents (test).
  • List and get work for documents without id/ptype (test).
  • Malformed requests yield 400, missing IDs 404, not 500 (tests).
  • save_policy called twice yields no duplicates (test).
  • No print(), no assert for runtime validation in the adapter.

Breaking changes

None for the HTTP API beyond #113/#112/#142. CasbinRule.dict() is renamed to to_dict() (internal).

Related

Simp #8; #113, #112, #142, #157

Activity

  1. added
    priority: medium
    type: bug
    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: mediumtype: bugtype: maintenanceworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions