I am trying out Solr 9.5 for the first time. I have installed Solr on my MacBook and can start it without any issues. The second step involves setting up Authorization and Authentication, which does not work when I follow the instructions.
The instructions for starting Solr in standalone mode (not cloud) involve creating a file named security.json, and adding the following to that file where solr.xml is /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"
}
}
}
The username is “solr,” and the password is SHA256 hashed and salted using the following Python code:
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()
It still doesn’t work, and when I restart and try, I get the following error:
Any idea what I am missing?