(新手问题提醒!) 我正在尝试在此 doc 之后在 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}}
答案 0 :(得分: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
此后,新构建的容器的行为如文档中所述。