Skip to content

Commit

Permalink
Merge pull request #251 from RockefellerArchiveCenter/development
Browse files Browse the repository at this point in the history
Add API authentication
  • Loading branch information
p-galligan authored Jan 23, 2025
2 parents 89cd09f + 7f693d7 commit 0f45030
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
scorpio-db:
image: postgres:14.4
Expand All @@ -26,7 +24,7 @@ services:
- scorpio-db

elasticsearch:
image: elasticsearch:7.9.3
image: elasticsearch:7.17.25
environment:
- node.name=elasticsearch
- discovery.seed_hosts=elasticsearch
Expand Down
7 changes: 4 additions & 3 deletions indexer/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ class Indexer:
"""

def __init__(self):
self.connection = connections.create_connection(
hosts=settings.ELASTICSEARCH['default']['hosts'], timeout=60
)
connection_args = {'hosts': settings.ELASTICSEARCH['default']['hosts'], 'timeout': 60}
if settings.ELASTICSEARCH['default'].get('api_key'):
connection_args['api_key'] = settings.ELASTICSEARCH['default']['api_key']
self.connection = connections.create_connection(**connection_args)
if not Index(settings.ELASTICSEARCH['default']['index']).exists():
BaseDescriptionComponent.init()
self.pisces_client = ElectronBond(baseurl=settings.PISCES['baseurl'])
Expand Down
1 change: 1 addition & 0 deletions scorpio/config.py.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ SQL_HOST = "${SQL_HOST}"
SQL_PORT = ${SQL_PORT}
ELASTICSEARCH_HOSTS = ${ELASTICSEARCH_HOSTS}
ELASTICSEARCH_INDEX = "${ELASTICSEARCH_INDEX}"
ELASTICSEARCH_API_KEY = "${ELASTICSEARCH_API_KEY}"
PISCES_BASEURL = "${PISCES_BASEURL}"
PISCES_POST_INDEX_PATH = "${PISCES_POST_INDEX_PATH}"
1 change: 1 addition & 0 deletions scorpio/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SQL_HOST = "scorpio-db" # host for the application database (string)
SQL_PORT = 5432 # port on which the application database can be reached (integer)
ELASTICSEARCH_HOSTS = ["elasticsearch:9200"] # hostnames (including ports, if applicable) at which Elasticsearch is available (list of strings)
ELASTICSEARCH_INDEX = "default" # name of Elasticsearch index to target (string)
ELASTICSEARCH_API_KEY = None # String of encoded API Key provided by Elasticsearch. Use None if not authenticating
MAX_OBJECTS = 1000 # maximum number of objects to be indexed at once (integer)
PISCES_BASEURL = "http://pisces-web:8007/" # base URL for an instance of Pisces (string)
PISCES_POST_INDEX_PATH = "/index-complete/" # path in Pisces which handles HTTP requests to indicate objects have been updated, default "/index-complete/" (string)
3 changes: 2 additions & 1 deletion scorpio/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@
ELASTICSEARCH = {
'default': {
'hosts': config.ELASTICSEARCH_HOSTS,
'index': config.ELASTICSEARCH_INDEX
'index': config.ELASTICSEARCH_INDEX,
'api_key': getattr(config, 'ELASTICSEARCH_API_KEY', None)
},
}

Expand Down

0 comments on commit 0f45030

Please sign in to comment.