3

(总初学者问题警报!)我正在尝试按照此文档在 SOLR 8.3(docker 容器:FROM solr:8.3)上设置基本身份验证:

我添加了 /var/solr/data/security.json:

{
"authentication":{ 
   "blockUnknown": true, 
   "class":"solr.BasicAuthPlugin",
   "credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}, 
   "realm":"My Solr users", 
   "forwardCredentials": false 
},
"authorization":{
   "class":"solr.RuleBasedAuthorizationPlugin",
   "permissions":[{"name":"security-edit",
      "role":"admin"}], 
   "user-role":{"solr":"admin"} 
}}

当我尝试更改默认管理员密码时:

curl --user solr:SolrRocks http://10.x.x.x:8983/solr/admin/authentication -H 'Content-type:application/json' -d '{"set-user": {"solr" : "MyNewSuperSecurePass" }}'

我得到错误:

  "responseHeader":{
    "status":400,
    "QTime":1},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"No authentication plugin configured",
    "code":400}}
4

1 回答 1

2

我发现只有在容器中运行 solr 时才会出现这种行为。基本上 security.json 文件必须在容器构建时放置。所以我添加到 Dockerfile 中:

FROM solr:8.3
ENV SOLR_USER="solr" \
    SOLR_GROUP="solr"
USER root
COPY --chown=solr:solr security/security.json /var/solr/data/security.json
USER $SOLR_USER

在此之后,新建容器的行为如文档中所述。

于 2021-03-22T12:38:01.627 回答