Xabaril / AspNetCore.Diagnostics.HealthChecks

Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Apache License 2.0
4.11k stars 801 forks source link

Add support for basic authentication to the Solr health check #2261

Open HalHunt opened 4 months ago

HalHunt commented 4 months ago

What would you like to be added: I didn't see a way to supply a username and password to the Solr health check. I tired to add the username and password to the SolrOptions.Uri as in http://solr:SolrRocks@localhost:8983/solr without success. Am I missing anything?

Why is this needed: To allow the Solr health check to be used in more realistic enterprise environments that use SSL and basic authentication.

The fix is relatively easy and I have a PR in the works however I need some guidance on unit tests. I have the correct new unit tests but I'm not sure how to support both Solr configurations (i.e. no auth and with auth) in the same docker container. Any guidance is greatly appreciated.

Alirexaa commented 4 months ago

Could you send PR? I will check it.

HalHunt commented 4 months ago

@Alirexaa done! https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/pull/2263

HalHunt commented 4 months ago

Found this to configure Solr to support both no auth + basic auth. blockUnknown is the key.

{
  "authentication":{ 
    "blockUnknown": false, 
    "class":"solr.BasicAuthPlugin",
    "credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}, 
    "realm":"solr", 
    "forwardCredentials": false 
  },
  "authorization":{
    "class":"solr.RuleBasedAuthorizationPlugin",
    "permissions":[{"name":"security-edit",
        "role":"admin"}], 
    "user-role":{"solr":"admin"} 
  }
}