Apache Solr open-source search software
SOLR-15573: bin/solr auth tool should provide role bindings for security-read and config-edit by default (#245)
Timothy Potterbe8ccfbfaf48
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex b53fee937f5..d13ceed6df7 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -408,6 +408,9 @@ Other Changes---------------------* SOLR-15566: Clarify ref guide documentation about SQL queries with `SELECT *` requiring a `LIMIT` clause (Timothy Potter)+* SOLR-15573: bin/solr auth utility should provide role bindings for `security-read` and `config-edit` by default+ to protect the security and schema designer screens in the Admin UI (Timothy Potter)+================== 8.9.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.diff --git a/solr/bin/solr b/solr/bin/solrindex 86d911d7aa5..be84209fdf5 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -1473,17 +1473,15 @@ if [[ "$SCRIPT_CMD" == "auth" ]]; then;;-prompt)AUTH_PARAMS=("${AUTH_PARAMS[@]}" "-prompt" "$2")- shift+ shift 2;;-blockUnknown)AUTH_PARAMS=("${AUTH_PARAMS[@]}" "-blockUnknown" "$2")- shift- break+ shift 2;;-updateIncludeFileOnly)AUTH_PARAMS=("${AUTH_PARAMS[@]}" "-updateIncludeFileOnly" "$2")- shift- break+ shift 2;;-V|--verbose)VERBOSE="-verbose"diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.javaindex 63fb737b1d4..ef91d7ab882 100755--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java@@ -4000,6 +4000,8 @@ public class SolrCLI implements CLIO {"\n \"class\":\"solr.RuleBasedAuthorizationPlugin\"," +"\n \"permissions\":[" +"\n {\"name\":\"security-edit\", \"role\":\"admin\"}," ++ "\n {\"name\":\"security-read\", \"role\":\"admin\"}," ++ "\n {\"name\":\"config-edit\", \"role\":\"admin\"}," +"\n {\"name\":\"collection-admin-edit\", \"role\":\"admin\"}," +"\n {\"name\":\"core-admin-edit\", \"role\":\"admin\"}" +"\n ]," +diff --git a/solr/solr-ref-guide/src/basic-authentication-plugin.adoc b/solr/solr-ref-guide/src/basic-authentication-plugin.adocindex e3ba25eaba6..7ef50ba41a3 100644--- a/solr/solr-ref-guide/src/basic-authentication-plugin.adoc+++ b/solr/solr-ref-guide/src/basic-authentication-plugin.adoc@@ -67,6 +67,14 @@ This has the effect of requiring authentication for HTTP access to Solr.In some cases, you may not want authentication after enabling the plugin; for example, if you want to have `security.json` in place but aren't ready to enable authentication.However, you will want to ensure that `blockUnknown` is set to `true` or omitted entirely in order for authentication to be enforced for all requests to your system.+[WARNING]+====+If you set `blockUnknown` to `false`, then *any* request that is not explicitly protected by a permission will be accessible by anonymous users!+Consequently, you should define a role binding for every <<rule-based-authorization-plugin.adoc#permissions,predefined>> permission you want to protect.+You can assign the special `role: null` binding for requests that you want to allow anonymous users to access. To protect all endpoints except those with `role:null`,+you can add a role binding for the `all` permission and place it in the last position in `security.json`.+====+If `realm` is not defined, it will default to `solr`.If you are using SolrCloud, you must upload `security.json` to ZooKeeper.diff --git a/solr/solr-ref-guide/src/security-ui.adoc b/solr/solr-ref-guide/src/security-ui.adocindex 1f8363b60ae..472237bb3ad 100644--- a/solr/solr-ref-guide/src/security-ui.adoc+++ b/solr/solr-ref-guide/src/security-ui.adoc@@ -103,6 +103,7 @@ However, if *Block anonymous requests* (`blockUnknown=true`) is checked, then anTo edit a permission, simply click on the corresponding row in the table. When editing a permission, the current index of the permission in the list of permissions is editable.This allows you to re-order permissions if needed; see <<rule-based-authorization-plugin.adoc#permission-ordering-and-resolution,Permission Ordering>>.+In general, you want to permissions listed from most specific to least specific in `security.json`.diff --git a/solr/webapp/web/js/angular/app.js b/solr/webapp/web/js/angular/app.jsindex 28ba743380b..1d04f97ddd5 100644--- a/solr/webapp/web/js/angular/app.js+++ b/solr/webapp/web/js/angular/app.js@@ -411,6 +411,9 @@ solrAdminApp.config([if (rejection.config.headers.doNotIntercept) {return rejection;}++ // Schema Designer handles errors internally to provide a better user experience than the global error handler+ var isHandledBySchemaDesigner = rejection.config.url && rejection.config.url.startsWith("/api/schema-designer/");if (rejection.status === 0) {$rootScope.$broadcast('connectionStatusActive');if (!$rootScope.retryCount) $rootScope.retryCount=0;@@ -418,7 +421,7 @@ solrAdminApp.config([var $http = $injector.get('$http');var result = $http(rejection.config);return result;- } else if (rejection.status === 401) {+ } else if (rejection.status === 401 && !isHandledBySchemaDesigner) {// Authentication redirectvar headers = rejection.headers();var wwwAuthHeader = headers['www-authenticate'];@@ -441,7 +444,6 @@ solrAdminApp.config([}} else {// schema designer prefers to handle errors itself- var isHandledBySchemaDesigner = rejection.config.url && rejection.config.url.startsWith("/api/schema-designer/");if (!isHandledBySchemaDesigner) {$rootScope.exceptions[rejection.config.url] = rejection.data.error;}@@ -548,7 +550,7 @@ solrAdminApp.controller('MainController', function($scope, $route, $rootScope, $SchemaDesigner.get({path: "configs"}, function (ignore) {// no-op, just checking if we have access to this path}, function(e) {- if (e.status === 403) {+ if (e.status === 401 || e.status === 403) {$scope.isSchemaDesignerEnabled = false;}});diff --git a/solr/webapp/web/js/angular/controllers/schema-designer.js b/solr/webapp/web/js/angular/controllers/schema-designer.jsindex a9c2e16a269..7b0204b741e 100644--- a/solr/webapp/web/js/angular/controllers/schema-designer.js+++ b/solr/webapp/web/js/angular/controllers/schema-designer.js@@ -168,7 +168,7 @@ solrAdminApp.controller('SchemaDesignerController', function ($scope, $timeout,$scope.showNewSchemaDialog();}}, function(e) {- if (e.status === 403) {+ if (e.status === 401 || e.status === 403) {$scope.isSchemaDesignerEnabled = false;$scope.hideAll();}diff --git a/solr/webapp/web/js/angular/controllers/security.js b/solr/webapp/web/js/angular/controllers/security.jsindex 93a120e253e..aa7ecd94534 100644--- a/solr/webapp/web/js/angular/controllers/security.js+++ b/solr/webapp/web/js/angular/controllers/security.js@@ -186,7 +186,6 @@ solrAdminApp.controller('SecurityController', function ($scope, $timeout, $cooki$scope.permFilterTypes = ["", "name", "role", "path", "collection"];System.get(function(data) {- // console.log(">> system: "+JSON.stringify(data));$scope.authenticationPlugin = data.security ? data.security["authenticationPlugin"] : null;$scope.authorizationPlugin = data.security ? data.security["authorizationPlugin"] : null;$scope.myRoles = data.security ? data.security["roles"] : [];@@ -196,7 +195,7 @@ solrAdminApp.controller('SecurityController', function ($scope, $timeout, $cooki$scope.solrHome = data["solr_home"];$scope.refreshSecurityPanel();}, function(e) {- if (e.status === 403) {+ if (e.status === 401 || e.status === 403) {$scope.isSecurityAdminEnabled = true;$scope.hasSecurityEditPerm = false;$scope.hideAll();diff --git a/solr/webapp/web/partials/security.html b/solr/webapp/web/partials/security.htmlindex b3b7b8af1bc..d777df956e8 100644--- a/solr/webapp/web/partials/security.html+++ b/solr/webapp/web/partials/security.html@@ -51,10 +51,10 @@ limitations under the License.<span ng-show="manageUsersEnabled" id="realm-field"><label for="realmName">Realm: </label><input disabled class="input-text" type="text" id="realmName" ng-model="realmName"></span>- <span id="block-field"><label for="block_unknown">Block anonymous requests?</label><input class="input-check" type="checkbox" id="block_unknown" ng-model="blockUnknown" ng-change="onBlockUnknownChange()" ng-true-value="'true'" ng-false-value="'false'"/><a ng-click="showHelp('blockUnknownHelp')"><img class="help-ico" src="img/ico/question-white.png"/></a>+ <span id="block-field" ng-show="manageUsersEnabled"><label for="block_unknown">Block anonymous requests?</label><input class="input-check" type="checkbox" id="block_unknown" ng-model="blockUnknown" ng-change="onBlockUnknownChange()" ng-true-value="'true'" ng-false-value="'false'"/><a ng-click="showHelp('blockUnknownHelp')"><img class="help-ico" src="img/ico/question-white.png"/></a><div id="blockUnknownHelp" class="help" ng-show="helpId === 'blockUnknownHelp'"><div class="help-top">- <p>If checked, un-authenticated requests to any Solr endpoint are blocked. If un-checked, then any endpoint that is not protected with a permission will be accessible by anonymous users. Only disable this check if you want to allow un-authenticated access to specific endpoints that are configured with <b>role: null</b>. For more information, see:+ <p>If checked, un-authenticated requests to any Solr endpoint are blocked. If un-checked, then any endpoint that is not protected with a permission will be accessible by anonymous users. Only disable this check if you want to allow un-authenticated access to specific endpoints that are configured with <b>role: null</b>. All other endpoints should be protected with explicit role bindings that require authentication. For more information, see:<div class="help-anchor"><a target="_blank" href="https://solr.apache.org/guide/basic-authentication-plugin.html#enable-basic-authentication">Basic Authentication</a></div></p></div></div>