Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API Authentication #326

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions argo/config.py.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ DJANGO_DEBUG = ${DJANGO_DEBUG}
DJANGO_SECRET_KEY = "${DJANGO_SECRET_KEY}"
DJANGO_STATIC_URL = "${DJANGO_STATIC_URL}"
DJANGO_ALLOWED_HOSTS = ${DJANGO_ALLOWED_HOSTS}
ELASTICSEARCH_AUTHENTICATION = ${ELASTICSEARCH_AUTHENTICATION}
ELASTICSEARCH_HOSTS = ${ELASTICSEARCH_HOSTS}
ELASTICSEARCH_INDEX = "${ELASTICSEARCH_INDEX}"
ELASTICSEARCH_CONNECTION = "${ELASTICSEARCH_CONNECTION}"
ELASTICSEARCH_API_KEY = "ELASTICSEARCH_API_KEY"
SQL_ENGINE = "${SQL_ENGINE}"
SQL_DATABASE = "${SQL_DATABASE}"
SQL_USER = "${SQL_USER}"
Expand Down
4 changes: 3 additions & 1 deletion argo/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ DJANGO_DEBUG = True # run Django in debug mode, which outputs stack traces to t
DJANGO_SECRET_KEY = "sx6mf&q*eifhk^(cx197+=*cuq0guy$43!+hy#g1l4orkklx$g" # used by Django to create hashes (string)
DJANGO_STATIC_URL = "/static/" # URL for static assets used by Django (string)
DJANGO_ALLOWED_HOSTS = ["localhost", "argo-web"] # hosts Argo will respond to (list of strings)
ELASTICSEARCH_AUTHENTICATION = False # Boolean to value to tell Argo whether it needs to authenticate to access the Elasticsearch cluster
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_CONNECTION = "default" # name of Elasticsearch connection to use (string)
ELASTICSEARCH_API_KEY = "FvWxPqRwTUI1Zlc2c09iRW1oJ632ajZqeWMtV2hSZFd1RHRzQUxQVXZqQQnn" # Encoded API Key provided by Elasticsearch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a real API key

SQL_ENGINE = "django.db.backends.postgresql" # the database engine used by Argo (string, one of django.db.backends)
SQL_DATABASE = "postgres" # name of the application database (string)
SQL_USER = "postgres" # name of the application database user (string)
Expand All @@ -15,4 +17,4 @@ USE_X_FORWARDED_HOST = False # Set to True if the application is behind a revers
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") # If the application is being a reverse proxy, and if a header value indicates an HTTPS connection proxied over HTTP, name that header and value (tuple)
CITATION_REPOSITORY_NAME = "Rockefeller Archive Center" # name of repository used in citations
CITATION_REPOSITORY_BASEURL = "https://dimes.rockarch.org/" # base url for citation links
CITATION_SEPARATOR = "; " # string to separate different parts of the citation
CITATION_SEPARATOR = "; " # string to separate different parts of the citation
3 changes: 3 additions & 0 deletions argo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
}
}

if config.ELASTICSEARCH_AUTHENTICATION == True:
ELASTICSEARCH_DSL['default']['api_key'] = config.ELASTICSEARCH_API_KEY

# CORS settings
CORS_ORIGIN_ALLOW_ALL = True

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
- argo-db

elasticsearch:
image: elasticsearch:7.9.3
image: elasticsearch:7.17.25
environment:
- node.name=elasticsearch
- discovery.seed_hosts=elasticsearch
Expand Down
Loading