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

Port: Add support for serving from custom path #202

Merged
merged 1 commit into from
Jan 27, 2025
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
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
7 changes: 5 additions & 2 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +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_PATH="/"

USER root

Expand All @@ -29,8 +30,10 @@ 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

# 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
Expand Down
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_PATH="
# - "OIDC_ISSUER="
# - "OIDC_CLIENT_ID="
# - "OIDC_SCOPE="
Expand Down
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 @@ -108,7 +108,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');
import common from '../../shared/common';

Expand All @@ -133,7 +133,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 @@ -6,7 +6,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