baptistegh opened a new pull request, #77585:
URL: https://github.com/apache/airflow/pull/77585

   The permission commands of the Keycloak auth manager build their role 
policies from the `Viewer`, `User`, `Op`, `Admin` and `SuperAdmin` roles, but 
no command created them and the docs did not say they had to exist. On a fresh 
realm, `create-permissions` and `create-all` failed with a bare Keycloak "role 
not found" error, and so did their `--dry-run`.
   
   This adds `airflow keycloak-auth-manager create-roles`, built like 
`create-scopes` and `create-resources`:
   
   - It creates the missing roles as client roles of the Airflow client. A role 
that already exists, as a realm role or as a client role, is left unchanged.
   - `--dry-run` lists the roles it would create.
   - `create-all` now creates the roles, before the role policies that need 
them.
   - `_ensure_role_policy` checks `--dry-run` before looking up the role, so 
`create-all --dry-run` works on a fresh realm.
   - The docs describe the new step and which role a policy uses when a realm 
role and a client role have the same name: the realm role, as before.
   
   Tested:
   
   - Unit tests of the provider: `uv run --project providers/keycloak pytest 
providers/keycloak/tests/unit/keycloak`: 463 passed.
   - Against Keycloak 23.0.6 (`breeze shell --integration keycloak --backend 
postgres`), with a fresh realm per scenario:
     - `create-roles --dry-run` lists the 5 roles and creates nothing.
     - `create-roles` creates the 5 client roles; a second run creates nothing 
more.
     - An existing `Admin` realm role is not duplicated as a client role.
     - `create-all --dry-run` and `create-all` succeed on a fresh realm.
     - Each `Allow-<role>` policy uses the client role created by the CLI, or 
the realm role when one exists.
   - `breeze build-docs keycloak`: successful.
   - `breeze run mypy` on the changed files: no issues.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Opus 5.5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to