Skip to content
Open
Changes from all 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
14 changes: 14 additions & 0 deletions conf/locations/opensearch.loc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Authorizes Dashboards against openIMIS rights, not merely a valid session.
# 200 right held, 403 right missing, 401 no session -> login.
# The 200 also carries X-Auth-User / X-Auth-Rights, copied upstream below.
location = /check_opensearch/ {
internal;
proxy_pass http://${backend}/${REACT_APP_API_URL}/opensearch_reports/auth_check;
Expand All @@ -13,6 +14,12 @@

location /opensearch/ {
auth_request /check_opensearch/;
# Identity from the 200, forwarded below. A backend that does not
# set them leaves these empty, and nginx then omits the header
# entirely rather than sending a blank one - so this gate can land
# before the backend that fills it does.
auth_request_set $auth_user $upstream_http_x_auth_user;
auth_request_set $auth_rights $upstream_http_x_auth_rights;
# auth_request can only deny; 403 passes through unchanged.
error_page 401 = @openimis_login;

Expand All @@ -22,6 +29,13 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Host $server_name;
# The cluster's proxy authenticator reads these two under whatever
# names its roles_header/user_header are set to, and files the codes
# as backend roles. Dashboards relays a header onwards only if it is
# listed in opensearch.requestHeadersAllowlist, which these are not
# yet - so for now they stop there.
proxy_set_header x-proxy-user $auth_user;
proxy_set_header x-proxy-rights $auth_rights;
proxy_set_header Authorization "Basic ${OPENSEARCH_BASIC_TOKEN}";

}
Expand Down
Loading