无法在 Solr 9.5 Standalone 中配置授权和身份验证

问题描述 投票:0回答:1

我是第一次尝试 Solr 9.5。我已经在 MacBook 上安装了 Solr,并且可以毫无问题地启动它。第二步涉及设置授权和身份验证,当我按照说明操作时,这不起作用。

以独立模式(非云)启动 Solr 的说明涉及创建一个名为 security.json 的文件,并将以下内容添加到该文件,其中 solr.xml 为 /opt/solr-9.5.0/server/solr:

{
"authentication": {
    "blockUnknown": true,
    "class": "solr.BasicAuthPlugin",
    "credentials": {
        "solr": "ymoqYYPJM0dyovJW0V/Sf6jNSD6ffYVjHcoR0skpcCU=:I5HY9Lf2RFAQi1/LJaFx4w=="
    },
    "realm": "My Solr users",
    "forwardCredentials": false
},
"authorization": {
    "class": "solr.RuleBasedAuthorizationPlugin",
    "permissions": [
        {
            "name": "security-edit",
            "role": "admin"
        }
    ],
    "user-role": {
        "solr": "admin"
    }
}

}

用户名是“solr”,密码是使用以下 Python 代码进行 SHA256 哈希和加盐处理的:

import hashlib
import os
import base64

def generate_sha256_hash_and_salt(password):
    salt = os.urandom(16)
    
    hash_obj = hashlib.sha256()
    
    hash_obj.update(password.encode('utf-8') + salt)
    
    hash_base64 = base64.b64encode(hash_obj.digest()).decode('utf-8')
    salt_base64 = base64.b64encode(salt).decode('utf-8')
    return f'{hash_base64}:{salt_base64}'

def main():
    password = input("Ange lösenordet du vill hash: ")
    combined_hash_salt = generate_sha256_hash_and_salt(password)
    print("Hash och Salt kombinerat för security.json:", combined_hash_salt)

if __name__ == "__main__":
    main()

enter image description here

仍然不起作用,当我重新启动并尝试时,出现以下错误: 知道我错过了什么吗?

authentication security solr configuration authorization
1个回答
0
投票

终于成功了。按照 Apache Solr 官方文档中提供的说明设置基本身份验证插件。 https://solr.apache.org/guide/solr/latest/deployment-guide/basic-authentication-plugin.html

配置身份验证的步骤

创建 security.json 文件并使用提供的 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"}
}}

用户名设置为

solr
,密码为
SolrRocks
。 SHA-256 加密密码已包含在 JSON 片段中。 重新启动 Solr: 正确设置 security.json 后,启动 Solr 并通过 Web 界面访问它,使用管理员凭据登录:用户名
solr
和密码
SolrRocks
。首次登录时更新密码。

© www.soinside.com 2019 - 2024. All rights reserved.