Skip to content

Commit

Permalink
Merge pull request ckan#6286 from ejdoh1/master
Browse files Browse the repository at this point in the history
Fixes HTTP basic auth cred handling
  • Loading branch information
amercader authored Aug 19, 2021
2 parents 37b3966 + 4240430 commit 9ac0650
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ckan/lib/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,11 @@ def clear_all():
def _get_schema_from_solr(file_offset):
solr_url, solr_user, solr_password = SolrSettings.get()

http_auth = None
if solr_user is not None and solr_password is not None:
http_auth = solr_user + ':' + solr_password
http_auth = 'Basic {}'.format(base64.b64encode(http_auth.encode('utf8')).strip())

url = solr_url.strip('/') + file_offset

if http_auth:
if solr_user is not None and solr_password is not None:
response = requests.get(
url, headers={'Authorization': http_auth})
url, auth=requests.auth.HTTPBasicAuth(solr_user, solr_password))
else:
response = requests.get(url)

Expand Down

0 comments on commit 9ac0650

Please sign in to comment.