Skip to content

Instantly share code, notes, and snippets.

@sstults
Created March 26, 2018 19:14
Show Gist options
  • Save sstults/8e2dc09fa50071a37283d5067ae1a711 to your computer and use it in GitHub Desktop.
Save sstults/8e2dc09fa50071a37283d5067ae1a711 to your computer and use it in GitHub Desktop.
Test Solr Auth/z
solr-6.6.2
solr start -c -e cloud
curl "http://localhost:8983/solr/gettingstarted/select?q=*:*"
curl "http://localhost:8983/solr/gettingstarted/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
cat > security.json <<EOM
{
"authentication":{
"blockUnknown": true,
"class":"solr.BasicAuthPlugin",
"credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}
},
"authorization":{
"class":"solr.RuleBasedAuthorizationPlugin",
"permissions":[{"name":"security-edit",
"role":"admin"},
{"name":"read", "role":"readonly"}],
"user-role":[{"solr":"admin"},{"tom":"read"},{"harry":"read"}]
}}
EOM
bin/solr zk cp security.json zk:/security.json -z localhost:9983
curl --user solr:SolrRocks http://localhost:8983/solr/admin/authentication -H 'Content-type:application/json' -d '{
"set-user": {"tom" : "TomIsCool" ,
"harry":"HarrysSecret"}}'
curl "http://localhost:8983/solr/gettingstarted/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
curl --user solr:SolrRocks "http://localhost:8983/solr/gettingstarted/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
curl "http://localhost:8983/solr/gettingstarted/select?q=*:*"
curl --user tom:TomIsCool "http://localhost:8983/solr/gettingstarted/select?q=*:*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment