Move index management privilege from Kibana to ElasticSearch#581
Conversation
|
Warning Review limit reached
More reviews will be available in 25 minutes and 27 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughElasticSearchIntegration gains index-management role control: a new config option stores IndexManagementResourceId, a method upserts the Elasticsearch security role with cluster and index privileges, startup triggers the upsert after resource initialization, resources are registered in Seacat Auth, and user authorization maps to the index_management role during credential sync. Legacy Kibana index-management wiring is removed. ChangesElasticsearch Index Management Role Migration
Sequence DiagramsequenceDiagram
participant Startup as ElasticsearchIntegration
participant InitRes as _initialize_resources()
participant UpRole as _upsert_index_management_role()
participant ES as Elasticsearch API
participant CredSync as Credential Sync
participant UserAuthz as User Authorization
Startup->>InitRes: register IndexManagementResourceId
InitRes-->>Startup: resources initialized
Startup->>UpRole: upsert index_management role
UpRole->>ES: GET _security/role/index_management
ES-->>UpRole: existing role privileges
UpRole->>UpRole: compare against required (cluster, indices)
alt Missing or different privileges
UpRole->>ES: PUT _security/role/index_management
ES-->>UpRole: role updated
end
CredSync->>UserAuthz: check user resources
UserAuthz-->>CredSync: includes IndexManagementResourceId?
alt User authorized
CredSync->>CredSync: add index_management to elk_roles
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@seacatauth/batman/elasticsearch.py`:
- Around line 444-445: The condition checking existing_index vs req_index has
mixed tabs/spaces and a problematic line break; fix by normalizing to spaces
(e.g., 4 spaces) and reformat the continuation so the binary operator is at the
start of the wrapped line or keep the whole expression inside the same
parenthesis-aligned block; specifically update the if statement that references
existing_index.get("names"), req_index.get("names"),
existing_index.get("privileges"), and req_index.get("privileges") so indentation
is consistent and the line break occurs before the 'and' (or keep the entire
condition on one line) to satisfy CI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 995edb4e-eaa3-4501-a24f-b2e3a56315ad
📒 Files selected for processing (1)
seacatauth/batman/elasticsearch.py
Summary by CodeRabbit
Release Notes
New Features
Configuration
Refactor