Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #99 from MITLibraries/solr-auth
Browse files Browse the repository at this point in the history
Add support for authenticating to Solr
  • Loading branch information
Mike Graves committed Jan 7, 2016
2 parents 80b366a + 4b77746 commit 61ec042
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app.json
Expand Up @@ -14,6 +14,8 @@
"PATH": "/app/.geodjango/gdal/bin:/usr/local/bin:/usr/bin:/bin",
"SECRET_KEY": "secret",
"SOLR_URL": "http://localhost:8983/solr/geoblacklight/",
"SOLR_AUTH_USER": {"required": true},
"SOLR_AUTH_PASS": {"required": true},
"SWORD_SERVICE_PASSWORD": "vorpalblade",
"SWORD_SERVICE_URL": "http://example.com/sword",
"SWORD_SERVICE_USERNAME": "swordymcswordmuffin",
Expand Down
2 changes: 2 additions & 0 deletions kepler/settings.py
Expand Up @@ -21,6 +21,8 @@ def __init__(self):
self.GEOSERVER_WORKSPACE = os.environ['GEOSERVER_WORKSPACE']
self.GEOSERVER_DATASTORE = os.environ['GEOSERVER_DATASTORE']
self.SOLR_URL = os.environ['SOLR_URL']
self.SOLR_AUTH_USER = os.environ['SOLR_AUTH_USER']
self.SOLR_AUTH_PASS = os.environ['SOLR_AUTH_PASS']
self.OAI_ORE_URL = os.environ['OAI_ORE_URL']
self.SWORD_SERVICE_URL = os.environ['SWORD_SERVICE_URL']
self.SWORD_SERVICE_USERNAME = os.environ['SWORD_SERVICE_USERNAME']
Expand Down
4 changes: 4 additions & 0 deletions kepler/tasks.py
Expand Up @@ -185,7 +185,11 @@ def _index_records(records):
:param records: iterator of dictionaries to be added to Solr
"""

auth = (current_app.config.get('SOLR_AUTH_USER'),
current_app.config.get('SOLR_AUTH_PASS'))
solr = pysolr.Solr(current_app.config['SOLR_URL'])
if all(auth):
solr.auth = auth
solr.add(records)


Expand Down

0 comments on commit 61ec042

Please sign in to comment.