solr has a basic authentication module. the description of how to generate the necessary hash + salt string is very hazy. there is this:
https://github.com/ansgarwiechers/solrpasswordhash
project with java code extracted from the solr source .... and then there is this:
#!/bin/bash
PW=$1
SALT=$(pwgen 48 -1)
echo "hash : $(echo -n "$SALT$PW" | sha256sum -b | xxd -r -p | sha256sum -b | xxd -r -p | base64 -w 1024) $(echo -n "$SALT" | base64 -w1024)"
to run this, you need to have pwgen and vim-common installed, eg (fedora)
dnf install pwgen vim-common -y
pwgen can obviously be replaced by anything that produces random strings. vim-common contains the "xxd" binary to convert hexadecimal output of sha256sum to binary.
you can then call this script:
script.sh "you_passw0rd"
and the out put goes in here:
"authentication": {
"blockUnknown": true,
"class": "solr.BasicAuthPlugin",
"credentials": {
"solr": "[***OUTPUT OF THE SCRIPT***]"
}
}
this script could be more elaborate - but i'd rather leave that as an execise to the reader :)
This is superb; thank you. Q: why is the
sha256sum -b | xxd -r -p | sha256sum -b | xxd -r -p
part duplicated? It's necessary, but I'm not following why that is.