Skip to content

BUG-30: an approval in an environment the role does not cover answers forbidden, not environment-forbidden #141

Closed

Description

@ephico2real2

Part of #14

What is wrong: An approval in an environment that the caller's role does not cover returns 403 with the code forbidden. The route declares environment-forbidden for this case, and :reject returns environment-forbidden for the same caller and the same request. So a client cannot tell "no role" from "wrong environment" on an approval.

Where: cmapi/src/cmapi/routers/requests.py:125, in approve. It passes permitted=c.cfg.roles.allowed(...) to the ledger, and cmapi/src/cmapi/core/approvals.py:280-282 raises a plain forbidden. The route reject calls c.cfg.roles.require(who, "requests:reject", row.env), which gives the right code.

How to prove it: In cmapi/tests/service/test_review_c_authz.py, with the rnd_only fixture, a caller with the role appr-rnd approves a request of dev. The response code must be environment-forbidden. Today it is forbidden.

Measured or inferred: Measured on 2026-11-13 with the service suite's fixtures, on macOS, PostgreSQL 16 on 127.0.0.1:55432. :approve returned "code": "forbidden", "detail": "Missing permission requests:approve for this environment". :reject returned "code": "environment-forbidden", "detail": "Your roles grant requests:reject only in ['rnd'], not dev".

Severity: Low. The call is refused in both cases. Only the code and the text are wrong.

What must hold after the fix: :approve returns 403 environment-forbidden with the environments that the role covers. A caller with no approving role still gets 403 forbidden. Each other check of the approval stays in its order: not-pending, already-approved, self-approval, not-eligible.

Research: Not necessary. The role policy's require already makes both answers (cmapi/src/cmapi/core/authz.py:157-165).

Solution (inline, not applied): Call c.cfg.roles.require(who, "requests:approve", row.env) in approve, at the place where reject calls it.

Class: No class. The fix brings the declared behaviour back and adds nothing.

Activity

  1. added
    bug
    status:open
    sev:low
    Backlog
    on Nov 13, 2026
  2. added
    In-Progress
    and removed
    Backlog
    on Nov 13, 2026
  3. ephico2real2 commented on Nov 13, 2026

    @ephico2real2
    OwnerAuthor

    In-Progress: the fix and its test are commit 99c4a42 on branch docs-authz, pushed, with no pull request yet. The test fails before the fix (code forbidden) and passes after it. A second reader checks it before the merge, because it changes an authorization answer.

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

    In-Progressbugsev:lowstatus:open

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions