Skip to content

refactor(access-control)!: drop header checks #276

Closed

Description

@uniqueg

Problem

There are two enforcement paths. check_permissions (foca/security/access_control/register_access_control.py) uses flask_authz.CasbinEnforcer, which reads the subject from request headers configured via CASBIN_OWNER_HEADERS/CASBIN_USER_NAME_HEADERS (AccessControlConfig.owner_headers/user_headers). These headers only carry claims because validate_token copies all claims into request.headers via request.headers.__dict__ and replaces the headers object. That drops the real headers, makes lookups case-sensitive, lets claims shadow header names, and on operations where validate_token did not run lets the client set its own identity. The second path (AccessControlResolver/enforce_access_control in enforcement.py) uses validated token_info claims, prefixes and groups, so the two can disagree. check_permissions also detects denial by inspecting flask-authz's (Response, 401) tuple. None of this works under Connexion 3.

Proposal

  • Remove check_permissions, the flask-authz dependency, CASBIN_OWNER_HEADERS/CASBIN_USER_NAME_HEADERS, and owner_headers/user_headers from AccessControlConfig.
  • Remove the header mutation from validate_token. Claims stay available via token_info and get_current_subject()/get_current_groups().
  • Make enforcement._get_claims stop swallowing AttributeError (only "no request context" means "no claims"), so a broken context import fails loudly (C3 2.8).
  • Builds on docs(examples): config-driven access control #271, which moved examples/petstore-access-control off check_permissions.

Acceptance criteria

  • check_permissions, flask-authz, header config keys and fields are gone; grep finds no references in code, docs, templates or examples.
  • Test: request.headers is unchanged after validate_token.
  • Test: enforcement denies when no validated claims are present, and a programming error in claim retrieval raises instead of silently returning {}.
  • README and docs/access_control/README.md describe one enforcement mechanism (config-driven) and how to read claims.
  • Migration note lists removed symbols and keys.

Breaking changes

Configs with owner_headers/user_headers fail validation (extra="forbid"): remove them. Code that imports check_permissions or reads claims or user_id from request.headers must use access_control.enforce and get_current_subject()/token_info. According to C3, neither proTES nor cloud-registry does; verify before release. Dependabot PR #272 (flask-authz bump) was closed for this reason.

Related

Sec #5; Simp #6 (header part), #7; C3 2.3, 2.8; #271, #272

Activity

  1. added
    priority: high
    type flag: breaking change
    type: auth
    type: security
    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: securityworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions