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

Added host to error page #33

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ui:
error_page_footer_text: Internal Systems - Authorized Access Only
logo_image_src: https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Google_2015_logo.svg/1200px-Google_2015_logo.svg.png
error_page_show_error_code: false
error_page_show_host: false

data_listen_port: 2080
metrics_listen_port: 9090
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/admin_page_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Scenario('I cant login to admin page as non admin', async ({ I }) => {
I.fillField('login', '[email protected]');
I.fillField('password', 'password');
I.click('Login');
I.see("Unauthorized")
I.see("Forbidden")
});


2 changes: 1 addition & 1 deletion test/e2e/tests/basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Scenario('Testing Token Auth', async ({ I }) => {
Scenario('Testing Unauthorized Flow', async ({ I }) => {
I.amOnPage('http://test-unauthorized-login.localtest.me/');
I.login()
I.see("Unauthorized")
I.see("Forbidden")
});

Scenario('Advanced matchers test', async ({ I }) => {
Expand Down
13 changes: 9 additions & 4 deletions util/errorpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ async function renderErrorPage(status_code, error_code_override, req) {
var footer_text = config?.ui?.error_page_footer_text || "Veriflow Access Proxy"
var background_image_url = config?.ui?.error_page_background || false
var additional_css = config?.ui?.error_page_additional_css || false
var request_host = req?.get("X-Forwarded-Host") || "{http.request.host}"
if (config?.ui?.error_page_show_host === false) {
request_host = null
}
var show_error_code = true
if (config?.ui?.error_page_show_error_code != null){
var show_error_code = config?.ui?.error_page_show_error_code
Expand All @@ -30,9 +34,9 @@ async function renderErrorPage(status_code, error_code_override, req) {
error_code = "ERR_NOT_FOUND"
}
if (status_code == 403) {
header = "Unauthorized"
description = "You are not authorized to access the requested resource."
error_code = "ERR_NOT_AUTHORIZED"
header = "Forbidden"
description = "You do not have permission to access the requested resource."
error_code = "ERR_ACCESS_DENIED"
}
if (status_code == 503) {
header = "Service Unavailable"
Expand Down Expand Up @@ -63,7 +67,8 @@ async function renderErrorPage(status_code, error_code_override, req) {
additional_css: additional_css,
show_error_code: show_error_code,
logo_image_src: logo_image_src,
request_id: req?.headers["X-Veriflow-Request-Id"] || "{http.request.uuid}"
request_id: req?.headers["X-Veriflow-Request-Id"] || "{http.request.uuid}",
request_host: request_host
});
return html
}
Expand Down
3 changes: 3 additions & 0 deletions views/error_fullpage.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<hr>
<p class="error-message"><%= description %></p>
</div>
<div class="footer">
<%= request_host %>
</div>
</div>
</body>
<footer>
Expand Down
Loading