← Back to Pull requests

Add resource-oriented v2 APIs for Basic Auth users and RBAC roles/permissions #4916

Open
unknown opened this pull request with 412 lines diff across 5 files
View on GitHub
unknown unknown commented on Sep 16, 2026 10:05 UTC
Author

Summary

Solr's existing v2 security endpoints (/api/cluster/security/authentication, /api/cluster/security/authorization) are command-batch-over-POST — the same set-user/set-permission/etc. commands as v1, just reachable at a v2 URL, not genuine resource-oriented REST. This PR adds a real resource-oriented v2 surface alongside the existing one, following the same JAX-RS/Jersey pattern already used by ClusterPropertyApis/AliasPropertyApis:

  • GET/PUT/DELETE /api/cluster/security/authentication/{scheme}/users/{username}

  • GET/PUT/DELETE /api/cluster/security/authorization/{scheme}/roles/{username}

  • GET/POST/PUT/DELETE /api/cluster/security/authorization/permissions/{index}
  • The {scheme} path segment lets these APIs work correctly under MultiAuthPlugin/MultiAuthRuleBasedAuthorizationPlugin (routing to the right sub-plugin's config), and is simply ignored for a plain BasicAuthPlugin/RuleBasedAuthorizationPlugin setup. Permissions have no such segment — MultiAuthRuleBasedAuthorizationPlugin.edit() already treats every *-permission command as shared across all schemes rather than per-scheme, so no wrapping is needed there.

    All mutations still funnel through SecurityConfHandler's existing CommandOperation/ConfigEditablePlugin machinery (extracted here into a new public editSecurityConfig() shared with the legacy v1/v2 command endpoints) — this is additive REST surface, not a rewrite of the security model or security.json semantics.

    Also included:

  • Wires the Admin UI's Security screen (security.js/services.js) to the new endpoints for user/role create/update/delete, following the existing AliasesV2-style generated-client pattern.

  • Documents the new endpoints in the ref guide (basic-authentication-plugin.adoc, rule-based-authorization-plugin.adoc).

  • Fixes a latent doc gap found along the way: rule-based-authorization-plugin.adoc was missing v2 URL examples for the existing command-batch authorization commands.
  • Test plan

  • SecurityV2ApiStandaloneTest — standalone-mode HTTP tests for all three resources via the generated SolrJ client (create/list/update/delete, including 401/404/409 error cases)

  • SecurityV2ApiCloudTest — SolrCloud-mode coverage; also catches and regression-tests a ClassCastException found via manual testing (Utils.getDeepCopy(..., mutable=false) wraps nested lists in Collections.unmodifiableCollection, not unmodifiableList, on the ZK-cached read path)

  • MultiAuthUsersAndRolesApiCloudTest — a genuine 2-scheme MultiAuthPlugin/MultiAuthRuleBasedAuthorizationPlugin cluster proving users/roles written to one scheme never leak into another

  • Manually verified end-to-end in a browser against a live Basic-Auth-enabled Solr instance (Admin UI Security screen: add/edit/delete user, set/clear roles, delete permission)

  • Existing security test suites (SecurityConfHandlerTest, V2SecurityAPIMappingTest, BasicAuthStandaloneTest, MultiAuthPluginTest, BasicAuthOnSingleNodeTest) pass unchanged

  • ./gradlew spotlessCheck forbiddenApisMain clean

  • Ref guide builds clean (./gradlew :solr:solr-ref-guide:checkSite)
  • 🤖 Generated with Claude Code

    https://claude.ai/code/session_01Kapco1bnqFBMkFHFPF6MFL

    Diff: 412 lines (+309 / -103) across 5 files Reviewer: sarkaramrit1993 Review duration: 108766m
    All Vouch review confidence checks passed
    Residual risk 0.42 = Change Risk (0.75) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 412 lines diff across 5 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #4916"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 44.7% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.1% (HIGH) · Higher = larger blast radius
    75.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 41.5% · Moderate risk
    41.5%
    Repository