mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 23:38:24 -04:00
Add API_PUBLIC_URL environment variable for public API access
- Added API_PUBLIC_URL to deploy-config and manifest.yml - Updated app config to load API_PUBLIC_URL from environment - Used API_PUBLIC_URL in CSP configuration for connect-src
This commit is contained in:
@@ -141,7 +141,7 @@ navigation = {
|
||||
def _csp(config):
|
||||
asset_domain = config["ASSET_DOMAIN"]
|
||||
logo_domain = config["LOGO_CDN_DOMAIN"]
|
||||
api_host_name = config["API_HOST_NAME"]
|
||||
api_public_url = config["API_PUBLIC_URL"]
|
||||
|
||||
csp = {
|
||||
"default-src": ["'self'", asset_domain],
|
||||
@@ -172,14 +172,14 @@ def _csp(config):
|
||||
"img-src": ["'self'", asset_domain, logo_domain],
|
||||
}
|
||||
|
||||
if api_host_name:
|
||||
csp["connect-src"].append(api_host_name)
|
||||
if api_public_url:
|
||||
csp["connect-src"].append(api_public_url)
|
||||
# this is for web socket
|
||||
if api_host_name.startswith("http://"):
|
||||
ws_url = api_host_name.replace("http://", "ws://")
|
||||
if api_public_url.startswith("http://"):
|
||||
ws_url = api_public_url.replace("http://", "ws://")
|
||||
csp["connect-src"].append(ws_url)
|
||||
elif api_host_name.startswith("https://"):
|
||||
ws_url = api_host_name.replace("https://", "wss://")
|
||||
elif api_public_url.startswith("https://"):
|
||||
ws_url = api_public_url.replace("https://", "wss://")
|
||||
csp["connect-src"].append(ws_url)
|
||||
return csp
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ class Config(object):
|
||||
NOTIFY_APP_NAME = "admin"
|
||||
NOTIFY_ENVIRONMENT = getenv("NOTIFY_ENVIRONMENT", "development")
|
||||
API_HOST_NAME = getenv("API_HOST_NAME", "localhost")
|
||||
API_PUBLIC_URL = getenv("API_PUBLIC_URL", "localhost")
|
||||
|
||||
ADMIN_BASE_URL = getenv("ADMIN_BASE_URL", "http://localhost:6012")
|
||||
HEADER_COLOUR = (
|
||||
"#81878b" # mix(govuk-colour("dark-grey"), govuk-colour("mid-grey"))
|
||||
|
||||
@@ -58,11 +58,11 @@ def view_job(service_id, job_id):
|
||||
|
||||
filter_args = parse_filter_args(request.args)
|
||||
filter_args["status"] = set_status_filters(filter_args)
|
||||
api_host_name = os.environ.get("API_HOST_NAME")
|
||||
api_public_url = os.environ.get("API_PUBLIC_URL")
|
||||
|
||||
return render_template(
|
||||
"views/jobs/job.html",
|
||||
api_host_name=api_host_name,
|
||||
api_public_url=api_public_url,
|
||||
FEATURE_SOCKET_ENABLED=current_app.config["FEATURE_SOCKET_ENABLED"],
|
||||
job=job,
|
||||
status=request.args.get("status", ""),
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{% if not job.finished_processing %}
|
||||
<p class="max-width-full">This page refreshes automatically to show the latest message activity delivery rates, details, and reports.<br>You can watch it in progress or check back later.</p>
|
||||
{% endif %}
|
||||
<div data-job-id="{{ job.id }}" data-feature="{{FEATURE_SOCKET_ENABLED | lower}}" data-host="{{ api_host_name }}">
|
||||
<div data-job-id="{{ job.id }}" data-feature="{{FEATURE_SOCKET_ENABLED | lower}}" data-host="{{ api_public_url }}">
|
||||
{% if not job.finished_processing %}
|
||||
<div
|
||||
data-resource="{{ updates_url }}"
|
||||
|
||||
Reference in New Issue
Block a user