Skip to content

Commit f7a3abf

Browse files
committed
Update settings.py
1 parent b0706ca commit f7a3abf

File tree

6 files changed

+43
-63
lines changed

6 files changed

+43
-63
lines changed

.secrets.baseline

+6-2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
{
7676
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
7777
},
78+
{
79+
"path": "detect_secrets.filters.common.is_baseline_file",
80+
"filename": ".secrets.baseline"
81+
},
7882
{
7983
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
8084
"min_level": 2
@@ -123,7 +127,7 @@
123127
"filename": "bin/settings.py",
124128
"hashed_secret": "347cd9c53ff77d41a7b22aa56c7b4efaf54658e3",
125129
"is_verified": false,
126-
"line_number": 46
130+
"line_number": 54
127131
}
128132
],
129133
"peregrine/blueprints/coremetadata.py": [
@@ -273,5 +277,5 @@
273277
}
274278
]
275279
},
276-
"generated_at": "2023-11-01T14:27:13Z"
280+
"generated_at": "2024-11-01T18:38:15Z"
277281
}

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ COPY poetry.lock pyproject.toml /${appname}/
2020
RUN poetry install -vv --only main --no-interaction
2121

2222
COPY --chown=gen3:gen3 . /$appname
23-
COPY --chown=gen3:gen3 ./deployment/wsgi/wsgi.py /$appname/wsgi.py
2423

2524
# Run poetry again so this app itself gets installed too
2625
RUN poetry install --without dev --no-interaction

bin/settings.py

+36-50
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from peregrine.api import app, app_init
22
from os import environ
3-
import confighelper
3+
import bin.confighelper as confighelper
44

55
APP_NAME = "peregrine"
66

@@ -12,74 +12,60 @@ def load_json(file_name):
1212
conf_data = load_json("creds.json")
1313
config = app.config
1414

15-
config["AUTH"] = "https://auth.service.consul:5000/v3/"
16-
config["AUTH_ADMIN_CREDS"] = None
17-
config["INTERNAL_AUTH"] = None
1815

1916
# ARBORIST deprecated, replaced by ARBORIST_URL
2017
# ARBORIST_URL is initialized in app_init() directly
2118
config["ARBORIST"] = "http://arborist-service/"
2219

23-
# Signpost: deprecated, replaced by index client.
24-
config["SIGNPOST"] = {
25-
"host": environ.get("SIGNPOST_HOST") or "http://indexd-service",
26-
"version": "v0",
27-
"auth": ("gdcapi", conf_data.get("indexd_password", "{{indexd_password}}")),
28-
}
20+
2921
config["INDEX_CLIENT"] = {
3022
"host": environ.get("INDEX_CLIENT_HOST") or "http://indexd-service",
3123
"version": "v0",
32-
"auth": ("gdcapi", conf_data.get("indexd_password", "{{indexd_password}}")),
24+
# The user should be "sheepdog", but for legacy reasons, we use "gdcapi" instead
25+
"auth": (
26+
(
27+
environ.get("INDEXD_USER", "gdcapi"),
28+
environ.get("INDEXD_PASS")
29+
or conf_data.get("indexd_password", "{{indexd_password}}"),
30+
)
31+
),
3332
}
34-
config["FAKE_AUTH"] = False
33+
3534
config["PSQLGRAPH"] = {
36-
"host": conf_data.get("db_host", "{{db_host}}"),
37-
"user": conf_data.get("db_username", "{{db_username}}"),
38-
"password": conf_data.get("db_password", "{{db_password}}"),
39-
"database": conf_data.get("db_database", "{{db_database}}"),
35+
"host": environ.get("PGHOST") or conf_data.get("db_host", "{{db_host}}"),
36+
"user": environ.get("PGUSER") or conf_data.get("db_username", "{{db_username}}"),
37+
"password": environ.get("PGPASSWORD")
38+
or conf_data.get("db_password", "{{db_password}}"),
39+
"database": environ.get("PGDB") or conf_data.get("db_database", "{{db_database}}"),
4040
}
4141

42-
config["HMAC_ENCRYPTION_KEY"] = conf_data.get("hmac_key", "{{hmac_key}}")
43-
config["FLASK_SECRET_KEY"] = conf_data.get("gdcapi_secret_key", "{{gdcapi_secret_key}}")
44-
config["PSQL_USER_DB_CONNECTION"] = "postgresql://%s:%s@%s:5432/%s" % tuple(
45-
[
46-
conf_data.get(key, key)
47-
for key in ["fence_username", "fence_password", "fence_host", "fence_database"]
48-
]
42+
fence_username = environ.get("FENCE_DB_USER") or conf_data.get(
43+
"fence_username", "{{fence_username}}"
44+
)
45+
fence_password = environ.get("FENCE_DB_PASS") or conf_data.get(
46+
"fence_password", "{{fence_password}}"
47+
)
48+
fence_host = environ.get("FENCE_DB_HOST") or conf_data.get(
49+
"fence_host", "{{fence_host}}"
50+
)
51+
fence_database = environ.get("FENCE_DB_DBNAME") or conf_data.get(
52+
"fence_database", "{{fence_database}}"
4953
)
54+
config["PSQL_USER_DB_CONNECTION"] = "postgresql://%s:%s@%s:5432/%s" % (
55+
fence_username,
56+
fence_password,
57+
fence_host,
58+
fence_database,
59+
)
60+
5061

5162
config["DICTIONARY_URL"] = environ.get(
5263
"DICTIONARY_URL",
5364
"https://s3.amazonaws.com/dictionary-artifacts/datadictionary/develop/schema.json",
5465
)
5566

56-
config["SUBMISSION"] = {"bucket": conf_data.get("bagit_bucket", "{{bagit_bucket}}")}
57-
58-
config["STORAGE"] = {
59-
"s3": {
60-
"access_key": conf_data.get("s3_access", "{{s3_access}}"),
61-
"secret_key": conf_data.get("s3_secret", "{{s3_secret}}"),
62-
}
63-
}
64-
65-
config["OIDC_ISSUER"] = "https://%s/user" % conf_data["hostname"]
66-
67-
config["OAUTH2"] = {
68-
"client_id": conf_data.get("oauth2_client_id", "{{oauth2_client_id}}"),
69-
"client_secret": conf_data.get("oauth2_client_secret", "{{oauth2_client_secret}}"),
70-
"api_base_url": "https://%s/user/" % conf_data["hostname"],
71-
"authorize_url": "https://%s/user/oauth2/authorize" % conf_data["hostname"],
72-
"access_token_url": "https://%s/user/oauth2/token" % conf_data["hostname"],
73-
"refresh_token_url": "https://%s/user/oauth2/token" % conf_data["hostname"],
74-
"client_kwargs": {
75-
"redirect_uri": "https://%s/api/v0/oauth2/authorize" % conf_data["hostname"],
76-
"scope": "openid data user",
77-
},
78-
# deprecated key values, should be removed after all commons use new oidc
79-
"internal_oauth_provider": "http://fence-service/oauth2/",
80-
"oauth_provider": "https://%s/user/oauth2/" % conf_data["hostname"],
81-
"redirect_uri": "https://%s/api/v0/oauth2/authorize" % conf_data["hostname"],
82-
}
67+
hostname = environ.get("CONF_HOSTNAME") or conf_data["hostname"]
68+
config["OIDC_ISSUER"] = "https://%s/user" % hostname
8369

8470
config["USER_API"] = config["OIDC_ISSUER"] # for use by authutils
8571
# use the USER_API URL instead of the public issuer URL to accquire JWT keys

deployment/wsgi/gunicorn.conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
wsgi_app = "deployment.wsgi.wsgi:application"
1+
wsgi_app = "bin.settings:application"
22
bind = "0.0.0.0:8000"
33
workers = 1
44
user = "gen3"

deployment/wsgi/wsgi.py

-5
This file was deleted.

peregrine/api.py

-4
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ def app_init(app):
133133
submission.graphql.make_graph_traversal_dict(app)
134134
app.graphql_schema = submission.graphql.get_schema()
135135
app.schema_file = submission.generate_schema_file(app.graphql_schema, app.logger)
136-
try:
137-
app.secret_key = app.config["FLASK_SECRET_KEY"]
138-
except KeyError:
139-
app.logger.error("Secret key not set in config! Authentication will not work")
140136
async_pool_init(app)
141137

142138
# ARBORIST deprecated, replaced by ARBORIST_URL

0 commit comments

Comments
 (0)