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

Feature: add support for serving from custom path #801

Merged
merged 8 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ docs/
node_modules/
release.sh
snapshot.sh
!docker/etc/nginx/conf.d/default.conf
!docker/etc/nginx/templates/default.conf.template
!docker/docker-entrypoint.d/*.sh
11 changes: 7 additions & 4 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ ENV TZ=Etc/UTC \
LANG=C.UTF-8 \
# Set default settings that may get overridden to empty values by
# the entrypoint script, if not explicitly provided by the user
OIDC_SCOPE="openid profile email"

OIDC_SCOPE="openid profile email" \
BASE_HREF="/"
nscuro marked this conversation as resolved.
Show resolved Hide resolved
USER root

# Copy the static HTML and JS files to the application directory
Expand All @@ -29,10 +29,13 @@ RUN chown -R 101:0 ${APP_DIR} \
# See https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/stable/alpine/Dockerfile#L139
USER 101

RUN mkdir /etc/nginx/templates
nscuro marked this conversation as resolved.
Show resolved Hide resolved
# Setup entrypoint
COPY --chown=101:0 ./docker/etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY --chown=101:0 ./docker/etc/nginx/templates/default.conf.template /etc/nginx/templates/default.conf.template

COPY --chmod=755 ./docker/docker-entrypoint.d/ /docker-entrypoint.d/


# Specify the container working directory
WORKDIR ${APP_DIR}

Expand All @@ -46,4 +49,4 @@ LABEL \
org.opencontainers.image.source="https://github.com/DependencyTrack/frontend" \
org.opencontainers.image.revision="${COMMIT_SHA}" \
org.opencontainers.image.licenses="Apache-2.0" \
maintainer="steve.springett@owasp.org"
maintainer="steve.springett@owasp.org"
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- dtrack-apiserver
environment:
- "API_BASE_URL=http://localhost:8081"
# - "BASE_HREF=/"
# - "OIDC_ISSUER="
# - "OIDC_CLIENT_ID="
# - "OIDC_SCOPE="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ server {
root /opt/owasp/dependency-track-frontend;
index index.html;
try_files $uri $uri/ /index.html;

sub_filter '<base href=/' '<base href=${BASE_HREF}';
sub_filter_once on;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
}
}
}
26 changes: 17 additions & 9 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Dependency-Track</title>
<base href="/" />
</head>
<body class="sidebar-minimized">
<noscript>
<strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong
>We're sorry but this app doesn't work properly without JavaScript
enabled. Please enable it to continue.</strong
>
</noscript>
<div id="app"></div>
<script type="text/javascript">
(function() {
(function () {
if (!sessionStorage.length) {
// Ask other tabs for session storage
localStorage.setItem('getSessionStorage', Date.now());
};
}
window.addEventListener('storage', function (event) {
if (event.key == 'getSessionStorage') {
// Some tab asked for the sessionStorage -> send it
localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage));
localStorage.setItem(
'sessionStorage',
JSON.stringify(sessionStorage),
);
localStorage.removeItem('sessionStorage');
} else if (event.key == 'sessionStorage' && !sessionStorage.length) {
// sessionStorage is empty -> fill it
var data = JSON.parse(event.newValue), value;
var data = JSON.parse(event.newValue),
value;
for (key in data) {
sessionStorage.setItem(key, data[key]);
}
Expand Down
2 changes: 1 addition & 1 deletion public/static/oidc-callback.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}
}

axios.get("/static/config.json")
axios.get("./config.json")
.then((response) => {
let config = response.data;

Expand Down
7 changes: 5 additions & 2 deletions src/views/pages/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import { ValidationObserver } from 'vee-validate';
import BValidatedInputGroupFormInput from '../../forms/BValidatedInputGroupFormInput';
import InformationalModal from '../modals/InformationalModal';
import EventBus from '../../shared/eventbus';
import { getRedirectUrl } from '../../shared/utils';
import { getRedirectUrl, getContextPath } from '../../shared/utils';
const qs = require('querystring');

export default {
Expand All @@ -125,7 +125,10 @@ export default {
userStore: new Oidc.WebStorageStateStore(),
authority: this.$oidc.ISSUER,
client_id: this.$oidc.CLIENT_ID,
redirect_uri: `${window.location.origin}/static/oidc-callback.html`,
redirect_uri:
getContextPath() !== ''
? `${window.location.origin}${getContextPath()}/static/oidc-callback.html`
: `${window.location.origin}/static/oidc-callback.html`,
response_type:
this.$oidc.FLOW === 'implicit' ? 'token id_token' : 'code',
scope: this.$oidc.SCOPE,
Expand Down
2 changes: 1 addition & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
productionSourceMap: false,
runtimeCompiler: true,
// Relative paths cannot be supported. Research by @nscur0 - https://owasp.slack.com/archives/CTC03GX9S/p1608400149085400
publicPath: '/',
publicPath: '.',
devServer: {
proxy: { '/api': { target: process.env.VUE_APP_SERVER_URL } },
},
Expand Down
Loading