Skip to content

Commit 6bf0722

Browse files
committed
Add support for serving from custom path
Ports DependencyTrack/frontend#801 Co-authored-by: Martijn van der Meij <[email protected]> Signed-off-by: nscuro <[email protected]> # Conflicts: # docker/etc/nginx/templates/default.conf.template
1 parent 304b5d4 commit 6bf0722

File tree

8 files changed

+31
-16
lines changed

8 files changed

+31
-16
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ docs/
1010
node_modules/
1111
release.sh
1212
snapshot.sh
13-
!docker/etc/nginx/conf.d/default.conf
13+
!docker/etc/nginx/templates/default.conf.template
1414
!docker/docker-entrypoint.d/*.sh

docker/Dockerfile.alpine

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ ENV TZ=Etc/UTC \
99
LANG=C.UTF-8 \
1010
# Set default settings that may get overridden to empty values by
1111
# the entrypoint script, if not explicitly provided by the user
12-
OIDC_SCOPE="openid profile email"
12+
OIDC_SCOPE="openid profile email" \
13+
BASE_PATH="/"
1314

1415
USER root
1516

@@ -29,8 +30,10 @@ RUN chown -R 101:0 ${APP_DIR} \
2930
# See https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/stable/alpine/Dockerfile#L139
3031
USER 101
3132

33+
RUN mkdir /etc/nginx/templates
34+
3235
# Setup entrypoint
33-
COPY --chown=101:0 ./docker/etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
36+
COPY --chown=101:0 ./docker/etc/nginx/templates/default.conf.template /etc/nginx/templates/default.conf.template
3437
COPY --chmod=755 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/
3538

3639
# Specify the container working directory

docker/docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
- dtrack-apiserver
1919
environment:
2020
- "API_BASE_URL=http://localhost:8081"
21+
# - "BASE_PATH="
2122
# - "OIDC_ISSUER="
2223
# - "OIDC_CLIENT_ID="
2324
# - "OIDC_SCOPE="

public/index.html

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
4-
<meta charset="utf-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
77
<title>Dependency-Track</title>
8+
<base href="/" />
89
</head>
910
<body class="sidebar-minimized">
1011
<noscript>
11-
<strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
12+
<strong
13+
>We're sorry but this app doesn't work properly without JavaScript
14+
enabled. Please enable it to continue.</strong
15+
>
1216
</noscript>
1317
<div id="app"></div>
1418
<script type="text/javascript">
15-
(function() {
19+
(function () {
1620
if (!sessionStorage.length) {
1721
// Ask other tabs for session storage
1822
localStorage.setItem('getSessionStorage', Date.now());
19-
};
23+
}
2024
window.addEventListener('storage', function (event) {
2125
if (event.key == 'getSessionStorage') {
2226
// Some tab asked for the sessionStorage -> send it
23-
localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage));
27+
localStorage.setItem(
28+
'sessionStorage',
29+
JSON.stringify(sessionStorage),
30+
);
2431
localStorage.removeItem('sessionStorage');
2532
} else if (event.key == 'sessionStorage' && !sessionStorage.length) {
2633
// sessionStorage is empty -> fill it
27-
var data = JSON.parse(event.newValue), value;
34+
var data = JSON.parse(event.newValue),
35+
value;
2836
for (key in data) {
2937
sessionStorage.setItem(key, data[key]);
3038
}

public/static/oidc-callback.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
}
3434
}
3535

36-
axios.get("/static/config.json")
36+
axios.get("./config.json")
3737
.then((response) => {
3838
let config = response.data;
3939

src/views/pages/Login.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ import { ValidationObserver } from 'vee-validate';
108108
import BValidatedInputGroupFormInput from '../../forms/BValidatedInputGroupFormInput';
109109
import InformationalModal from '../modals/InformationalModal';
110110
import EventBus from '../../shared/eventbus';
111-
import { getRedirectUrl } from '../../shared/utils';
111+
import { getRedirectUrl, getContextPath } from '../../shared/utils';
112112
const qs = require('querystring');
113113
import common from '../../shared/common';
114114
@@ -133,7 +133,10 @@ export default {
133133
userStore: new Oidc.WebStorageStateStore(),
134134
authority: this.$oidc.ISSUER,
135135
client_id: this.$oidc.CLIENT_ID,
136-
redirect_uri: `${window.location.origin}/static/oidc-callback.html`,
136+
redirect_uri:
137+
getContextPath() !== ''
138+
? `${window.location.origin}${getContextPath()}/static/oidc-callback.html`
139+
: `${window.location.origin}/static/oidc-callback.html`,
137140
response_type:
138141
this.$oidc.FLOW === 'implicit' ? 'token id_token' : 'code',
139142
scope: this.$oidc.SCOPE,

vue.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
productionSourceMap: false,
77
runtimeCompiler: true,
88
// Relative paths cannot be supported. Research by @nscur0 - https://owasp.slack.com/archives/CTC03GX9S/p1608400149085400
9-
publicPath: '/',
9+
publicPath: '.',
1010
devServer: {
1111
proxy: { '/api': { target: process.env.VUE_APP_SERVER_URL } },
1212
},

0 commit comments

Comments
 (0)