Repository navigation
Give declared users view or edit access to Kibana (S-024-6, S-024-7) - #611
Conversation
There was a problem hiding this comment.
Review: MERGE at 42bea4e. No fix commits.
Checks: ruff, mypy, ansible-lint (CI config) clean; touched tests 67 passed (new S-024 access tests, S-012 users and role tests, S-024 Kibana role tests). specs.py coverage --spec 024 lists tests for S-024-6 and S-024-7; its exit 1 is for criteria other issues build.
Verified: the password hash is sent only for a new user or a changed stored hash, so granting or taking Kibana access never resets a password, and nothing in S-012 relied on the resend. Users not named in kibana.users get no request; removing a line drops only the Kibana role; a second converge changes nothing. The S-012 cleanup deletes only roles tagged with the Elasticsearch service id, so the Kibana roles survive. services.yml picks the cluster by kibana.elasticsearch. Every password task is no_log; the two roles hold no cluster, index, or run_as privilege.
Unverified live: a real login, a refused save, Kibana 9's role response (stand-in API only).
Notes (not blocking):
- F-1 (nit):
cloudfall_inspect/tasks/elasticsearch_users.yml:97-102: audit lists the two Kibana roles as not made by Cloudfall; status stays compliant. Fits S-024-13 (#582) - F-2 (nit): removing the Kibana service leaves both roles on the cluster
History: H-1, H-7, H-9 consistent; the rest unrelated; #610 and #597 also edit services.yml.
The Kibana role keeps cloudfall-kibana-view (base read) and cloudfall-kibana-edit (base all) on every space, with no Elasticsearch privilege, through Kibana's role API, reading each first so a second converge puts nothing. services.yml hands the Elasticsearch role the access of each user its cluster's Kibana names, and the S-012 user converge gives that user the matching Kibana role next to its own role, taking it away when the line is removed. Users Kibana does not name keep exactly their own role. A change of roles alone sends no password hash, so a password the person changed in Kibana stays. Fixes #572 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42bea4e to
4582661
Compare
There was a problem hiding this comment.
Review: MERGE at 4582661, the earlier MERGE review of 42bea4e rebased onto main after #610 (Kibana published through a Domain) landed.
git range-diffreads the PR's one commit as identical (42bea4e = 4582661); the rebase was clean- #610 and this PR both edit
engine/ansible/playbooks/services.ymlandcloudfall_kibana/tasks/main.yml, in separate places. The newroles.ymlstill calls Kibana oncloudfall_kibana_url, the loopback listener #610 keeps for the role's own calls, so publishing through a Domain doesn't change where the role API is reached - Ran on the rebased tree:
pytestontest_s024_kibana_access.py,test_s024_8_kibana_domain.py,test_s024_kibana_role.py,test_s012_elasticsearch_users.py(50 passed);changelog_guard.py checkclean (one fragment) - CI on 4582661:
checks,checks (Python 3.15)andconvergegreen
Unverified live, as the PR body lists: logins and refused saves in a real Kibana, the shape of Kibana 9's role API answer, and Elasticsearch keeping a password on a PUT without password_hash.
Plan
engine/ansible/roles/cloudfall_kibana/tasks/roles.yml(new),engine/ansible/roles/cloudfall_kibana/tasks/main.yml(one include),engine/ansible/roles/cloudfall_elasticsearch/tasks/users.yml,engine/ansible/roles/cloudfall_elasticsearch/defaults/main.yml,engine/ansible/roles/cloudfall_elasticsearch/meta/argument_specs.yml,engine/ansible/playbooks/services.yml,engine/tests/test_s024_kibana_access.py(new),changelog.d/572-kibana-access.mdcloudfall-kibana-view(baseread) andcloudfall-kibana-edit(baseall) on every space, with no Elasticsearch privilege, through Kibana's role API, reading each first so an unchanged role is not put again; (2)services.ymlhands the Elasticsearch role theaccessof each user the cluster's Kibana service names; (3) the S-012 user converge gives a named user the Kibana role of its access next to its own role, takes it from a user no longer named, and leaves an unnamed user's roles exactly as they are; a change of roles alone sends no password hash, so a password the person changed in Kibana stays (S-024, People and what they may do); (4) tests, changelog fragmentengine/tests/test_s024_kibana_access.pyruns the user tasks and the role tasks for real withansible-playbookagainst stand-ins of Elasticsearch's security API and Kibana's role API (the roles each request puts, a second converge putting nothing, taking access away, the users' own roles holding no application privilege,no_logon every task that sees a password); what only a live Kibana proves (logging in, a data view and a dashboard, a refused save) is listed as unverifiedSummary
Builds S-024-6 and S-024-7 of spec 024: who may work in Kibana.
cloudfall_kibana/tasks/roles.yml, included frommain.ymlonce Kibana reports itself available, never in check mode):cloudfall-kibana-viewis Kibana's base privilegereadandcloudfall-kibana-editits baseall, both on every space (spaces: ["*"]) with emptycluster,indicesandrun_as, so neither reaches an index or manages users and roles. They are written withPUT /api/security/role/<name>(withkbn-xsrf), after aGETof each: a role already holding exactly that is not put again, one changed by hand is. They carrymetadata.cloudfall_managed_by: <kibana service id>, so the S-012 user converge, which only deletes roles marked with the Elasticsearch service's id, never touches them. As the maintainer accepted for Kibana service: Kibana converged on a node, with its token and keys (S-024-3, S-024-4, S-024-5) #569, the role talks to Kibana as thecloudfallaccount over loopbackservices.ymlhands the Elasticsearch rolecloudfall_elasticsearch_kibana_access, theaccessof each user named inkibana.usersof the cluster's Kibana service, read from every server'scloudfall_services(the Kibana service lands on its own server only, which need not be the home that converges users).users.ymlputs a named user with[<own role>, cloudfall-kibana-<access>]and an unnamed one with[<own role>], as before. The user's own role is untouched: a dashboard shows that person only itsindexPatternsPUTnow carriespassword_hashonly when the user is new or its stored password's digest changed. Giving or taking Kibana access (or re-enabling a user) no longer resends the hash, so a password the person changed in Kibana stays, as the spec's People section says. A rotated password is still sentA name in
kibana.usersthat the Elasticsearch service does not declare is already refused at validation (service_kibana_user_unknown, #567).Test notes
engine/tests/test_s024_kibana_access.py(12 tests). The user tasks ofcloudfall_elasticsearchand the role tasks ofcloudfall_kibanarun for real withansible-playbook -vvv --diffon localhost against one stand-in answering Elasticsearch's security API and Kibana's role API (it refuses a KibanaPUTwithoutkbn-xsrf, and keeps a Kibana role as Elasticsearch does, with privileges ofkibana-.kibana). They prove the two role bodies, analyst and support holding their own role plus the Kibana role of their access, no index of either reachingbilling-1, a second converge withchanged=0and no write, an unnamed user holding its own role alone with no application privilege, access given to a converged cluster touching only the named users and sending no hash, removinganalystsending one userPUTwith no hash and leaving its role and password, a role changed by hand being put again, a rotated password still sent, no password or hash in the output,no_logon every task seeing the password, and theservices.ymlexpression finding the access when Kibana runs on a node other than the homespecs.py coverage --spec 024lists tests for S-024-6 and S-024-7ruff check .,mypy,ansible-lint engine/ansible(withANSIBLE_CONFIG=engine/ansible/ansible.cfg, as CI), andpyteston the new file plustest_s012_elasticsearch_users.py,test_s024_kibana_role.py,test_s012_elasticsearch_role.py,test_s023_rabbitmq_role.py,test_s024_kibana_render.py(91 passed). The full suite is left to CIUnverified live (needs a Debian 13 host with Elastic's packages):
analystlogging in, creating a data view oncrm-*and a dashboard, and seeing no document ofbilling-1;supportopening it and being refused a saveanalystafter removal, getting Kibana's no-access page whileanalyst's search ofcrm-1still worksGET /api/security/role/<name>answers (the comparison defaults missing keys, and readsremote_indicestoo), and Kibana accepting thecloudfallfile-realm superuser for its role APIPUTwithoutpassword_hashFixes #572
🤖 Generated with Claude Code