Skip to content
Snippets Groups Projects
Commit 8bf5bc16 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Split the app config out into a separate file

parent e39b4964
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ test:
stage: test
script:
- yarn install
- yarn run build-dev
- APP_ENV=development yarn run build
- yarn run test-full
linting:
......
export default {
local: {
basePath: '/dist/',
entryPointURL: 'http://127.0.0.1:8000',
keyCloakBaseURL: 'https://auth-dev.tugraz.at/auth',
keyCloakClientId: 'auth-dev-mw-frontend-local',
matomoUrl: 'https://analytics.tugraz.at/',
matomoSiteId: 131,
nextcloudBaseURL: 'http://localhost:8081',
pdfAsQualifiedlySigningServer: 'https://sig-dev.tugraz.at',
},
bs: {
basePath: '/dist/',
entryPointURL: 'http://bs-local.com:8000',
keyCloakBaseURL: 'https://auth-test.tugraz.at/auth',
keyCloakClientId: 'auth-dev-mw-frontend-local',
matomoUrl: 'https://analytics.tugraz.at/',
matomoSiteId: 131,
nextcloudBaseURL: 'http://bs-local.com:8081',
pdfAsQualifiedlySigningServer: 'https://sig-dev.tugraz.at',
},
development: {
basePath: '/apps/signature/',
entryPointURL: 'https://mw-dev.tugraz.at',
keyCloakBaseURL: 'https://auth-dev.tugraz.at/auth',
keyCloakClientId: 'esign-dev_tugraz_at-ESIGN',
matomoUrl: 'https://analytics.tugraz.at/',
matomoSiteId: 131,
nextcloudBaseURL: 'https://nc-dev.tugraz.at/pers',
pdfAsQualifiedlySigningServer: 'https://sig-dev.tugraz.at',
},
demo: {
basePath: '/apps/signature/',
entryPointURL: 'https://api-demo.tugraz.at',
keyCloakBaseURL: 'https://auth-test.tugraz.at/auth',
keyCloakClientId: 'esig-demo_tugraz_at-ESIG',
matomoUrl: 'https://analytics.tugraz.at/',
matomoSiteId: 131,
nextcloudBaseURL: 'https://cloud.tugraz.at',
pdfAsQualifiedlySigningServer: 'https://sig-test.tugraz.at',
},
production: {
basePath: '/',
entryPointURL: 'https://api.tugraz.at',
keyCloakBaseURL: 'https://auth.tugraz.at/auth',
keyCloakClientId: 'esig_tugraz_at',
matomoUrl: 'https://analytics.tugraz.at/',
matomoSiteId: 137,
nextcloudBaseURL: '',
pdfAsQualifiedlySigningServer: 'https://sig.tugraz.at',
},
};
\ No newline at end of file
......@@ -4,7 +4,7 @@ DirectoryIndex <%= getUrl(name + '.html') %>
</FilesMatch>
Header set Cache-Control "must-revalidate, max-age=60"
Header set Content-Security-Policy "default-src 'self' 'unsafe-eval' 'unsafe-inline' analytics.tugraz.at <%= keyCloakServer %> <%= entryPointURL %> httpbin.org <%= nextcloudBaseURL %> www.handy-signatur.at <%= pdfAsQualifiedlySigningServer %>; img-src * blob: data:"
Header set Content-Security-Policy "default-src 'self' 'unsafe-eval' 'unsafe-inline' <%= matomoUrl %> <%= keyCloakServer %> <%= entryPointURL %> httpbin.org <%= nextcloudBaseURL %> www.handy-signatur.at <%= pdfAsQualifiedlySigningServer %>; img-src * blob: data:"
# Apache adds a "-gzip" suffix to the etag when it uses gzip but doesn't
# take that into account when receiving requests.
......
......@@ -65,7 +65,7 @@
src="<%= getUrl(name + '.topic.metadata.json') %>"
base-path="<%= getUrl('') %>"
keycloak-config='{"url": "<%= keyCloakBaseURL %>", "realm": "tugraz", "clientId": "<%= keyCloakClientId %>", "silentCheckSsoRedirectUri": "<%= getUrl('silent-check-sso.html') %>"}'
matomo-url='https://analytics.tugraz.at/'
matomo-url='<%= matomoUrl %>'
matomo-site-id='<%= matomoSiteId %>'
><dbp-loading-spinner></dbp-loading-spinner></<%= name %>>
</dbp-provider>
......
......@@ -42,30 +42,16 @@ host('production')
->hostname('mw@mw01-prod.tugraz.at')
->set('deploy_path', '/home/mw/prod_esig/deploy');
// Demo build task
task('build-demo', function () {
task('build', function () {
$stage = get('stage');
runLocally("yarn install");
runLocally("yarn run build-demo");
})->onStage('demo');
// Demo dev task
task('build-development', function () {
runLocally("yarn install");
runLocally("yarn run build-dev");
})->onStage('development');
//Production task
task('build-production', function () {
runLocally("yarn install");
runLocally("yarn run build-prod");
})->onStage('production');
runLocally("APP_ENV=$stage yarn run build");
});
// Deploy task
task('deploy', [
'deploy:info',
'build-demo',
'build-development',
'build-production',
'build',
'deploy:prepare',
'deploy:lock',
'deploy:release',
......
......@@ -14,7 +14,6 @@
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-replace": "^2.3.3",
"@rollup/plugin-url": "^6.0.0",
"babel-eslint": "^10.0.3",
"chai": "^4.2.0",
......@@ -41,8 +40,8 @@
"@dbp-toolkit/app-shell": "^0.1.0",
"@dbp-toolkit/auth": "^0.1.0",
"@dbp-toolkit/common": "^0.1.0",
"@dbp-toolkit/font-source-sans-pro": "^0.1.0",
"@dbp-toolkit/file-handling": "^0.1.0",
"@dbp-toolkit/font-source-sans-pro": "^0.1.0",
"@dbp-toolkit/language-select": "^0.1.0",
"@dbp-toolkit/notification": "^0.1.0",
"@dbp-toolkit/person-profile": "^0.1.0",
......@@ -58,16 +57,14 @@
"webdav": "^3.3.0"
},
"scripts": {
"build-dev": "rollup -c --environment BUILD:development",
"build-prod": "rollup -c --environment BUILD:production",
"build-demo": "rollup -c --environment BUILD:demo",
"build": "rollup -c",
"i18next": "i18next-scanner",
"watch": "rollup -c --watch",
"watch-local": "yarn run watch",
"watch-full": "rollup -c --watch --environment FORCE_FULL",
"watch-bs": "rollup -c --watch --environment BUILD:bs",
"test": "rollup -c --environment BUILD:test && karma start --singleRun",
"test-full": "rollup -c --environment FORCE_FULL,BUILD:test && karma start --singleRun",
"watch-bs": "rollup -c --watch --environment APP_ENV:bs",
"test": "rollup -c --environment APP_ENV:test && karma start --singleRun",
"test-full": "rollup -c --environment FORCE_FULL,APP_ENV:test && karma start --singleRun",
"lint": "eslint ."
}
}
......@@ -7,7 +7,6 @@ import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import {terser} from "rollup-plugin-terser";
import json from '@rollup/plugin-json';
import replace from "@rollup/plugin-replace";
import serve from 'rollup-plugin-serve';
import urlPlugin from "@rollup/plugin-url";
import consts from 'rollup-plugin-consts';
......@@ -16,6 +15,7 @@ import del from 'rollup-plugin-delete';
import emitEJS from 'rollup-plugin-emit-ejs'
import {getBabelOutputPlugin} from '@rollup/plugin-babel';
import selfsigned from 'selfsigned';
import appConfig from './app.config.js';
// -------------------------------
......@@ -27,103 +27,48 @@ const USE_HTTPS = false;
// -------------------------------
const pkg = require('./package.json');
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
const appEnv = (typeof process.env.APP_ENV !== 'undefined') ? process.env.APP_ENV : 'local';
const watch = process.env.ROLLUP_WATCH === 'true';
const buildFull = (!watch && build !== 'test') || (process.env.FORCE_FULL !== undefined);
console.log("build: " + build);
let basePath = '';
let entryPointURL = '';
let nextcloudBaseURL = 'https://cloud.tugraz.at';
let nextcloudWebAppPasswordURL = nextcloudBaseURL + '/apps/webapppassword';
let nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
let nextcloudName = 'TU Graz cloud';
let keyCloakServer = '';
let keyCloakBaseURL = '';
let keyCloakClientId = '';
let pdfAsQualifiedlySigningServer = '';
let matomoSiteId = 131;
const buildFull = (!watch && appEnv !== 'test') || (process.env.FORCE_FULL !== undefined);
let useTerser = buildFull;
let useBabel = buildFull;
let checkLicenses = buildFull;
switch (build) {
case 'local':
basePath = '/dist/';
entryPointURL = 'http://127.0.0.1:8000';
nextcloudBaseURL = 'http://localhost:8081';
nextcloudWebAppPasswordURL = nextcloudBaseURL + '/index.php/apps/webapppassword';
nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
keyCloakServer = 'auth-dev.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'auth-dev-mw-frontend-local';
pdfAsQualifiedlySigningServer = 'sig-dev.tugraz.at';
break;
case 'development':
basePath = '/apps/signature/';
entryPointURL = 'https://mw-dev.tugraz.at';
// "/pers" can't go here because it's not allowed in the "Content-Security-Policy"
nextcloudBaseURL = 'https://nc-dev.tugraz.at';
// "/index.php" is needed to don't get a "This origin is not allowed!" because the "target-origin" get parameter can't be read
nextcloudWebAppPasswordURL = nextcloudBaseURL + '/pers/index.php/apps/webapppassword';
nextcloudWebDavURL = nextcloudBaseURL + '/pers/remote.php/dav/files';
keyCloakServer = 'auth-dev.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'esign-dev_tugraz_at-ESIGN';
pdfAsQualifiedlySigningServer = 'sig-dev.tugraz.at';
break;
case 'demo':
basePath = '/apps/signature/';
entryPointURL = 'https://api-demo.tugraz.at';
// "/pers" can't go here because it's not allowed in the "Content-Security-Policy"
nextcloudBaseURL = 'https://cloud.tugraz.at';
// "/index.php" is needed to don't get a "This origin is not allowed!" because the "target-origin" get parameter can't be read
nextcloudWebAppPasswordURL = nextcloudBaseURL + '/index.php/apps/webapppassword';
nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
keyCloakServer = 'auth-test.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'esig-demo_tugraz_at-ESIG';
pdfAsQualifiedlySigningServer = 'sig-test.tugraz.at';
break;
case 'production':
basePath = '/';
entryPointURL = 'https://api.tugraz.at';
nextcloudBaseURL = '';
nextcloudWebAppPasswordURL = nextcloudBaseURL + '';
nextcloudWebDavURL = nextcloudBaseURL + '';
keyCloakServer = 'auth.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'esig_tugraz_at';
pdfAsQualifiedlySigningServer = 'sig.tugraz.at';
matomoSiteId = 137;
break;
case 'test':
basePath = '/apps/signature/';
entryPointURL = '';
nextcloudBaseURL = '';
nextcloudWebAppPasswordURL = '';
keyCloakServer = '';
keyCloakBaseURL = '';
keyCloakClientId = '';
pdfAsQualifiedlySigningServer = '';
break;
case 'bs':
basePath = '/dist/';
entryPointURL = 'http://bs-local.com:8000';
nextcloudBaseURL = 'http://bs-local.com:8081';
nextcloudWebAppPasswordURL = nextcloudBaseURL + '/index.php/apps/webapppassword';
nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
keyCloakServer = 'auth-dev.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'auth-dev-mw-frontend-local';
pdfAsQualifiedlySigningServer = 'sig-dev.tugraz.at';
break;
default:
console.error('Unknown build environment: ' + build);
console.log("APP_ENV: " + appEnv);
let config;
if (appEnv in appConfig) {
config = appConfig[appEnv];
} else if (appEnv === 'test') {
config = {
basePath: '/',
entryPointURL: 'https://test',
keyCloakBaseURL: 'https://test',
keyCloakClientId: '',
matomoUrl: '',
matomoSiteId: -1,
nextcloudBaseURL: 'https://test',
pdfAsQualifiedlySigningServer: 'https://test'
};
} else {
console.error(`Unknown build environment: '${appEnv}', use one of '${Object.keys(appConfig)}'`);
process.exit(1);
}
let nextcloudFileURL = nextcloudBaseURL + '/apps/files/?dir=';
config.keyCloakServer = new URL(config.keyCloakBaseURL).origin;
config.nextcloudName = 'TU Graz cloud';
if (config.nextcloudBaseURL) {
config.nextcloudFileURL = config.nextcloudBaseURL + '/index.php/apps/files/?dir=';
config.nextcloudOrigin = new URL(config.nextcloudBaseURL).origin;
config.nextcloudWebAppPasswordURL = config.nextcloudBaseURL + '/index.php/apps/webapppassword';
config.nextcloudWebDavURL = config.nextcloudBaseURL + '/remote.php/dav/files';
} else {
config.nextcloudFileURL = '';
config.nextcloudOrigin = '';
config.nextcloudWebAppPasswordURL = '';
config.nextcloudWebDavURL = '';
}
/**
* Creates a server certificate and caches it in the .cert directory
......@@ -164,7 +109,7 @@ function getBuildInfo() {
info: commit,
url: newUrl,
time: new Date().toISOString(),
env: build
env: appEnv
}
}
......@@ -184,7 +129,7 @@ export async function getPackagePath(packageName, assetPath) {
}
export default (async () => {return {
input: (build != 'test') ? [
input: (appEnv != 'test') ? [
'src/' + pkg.name + '.js',
'vendor/toolkit/packages/provider/src/dbp-provider.js',
'src/dbp-official-signature-pdf-upload.js',
......@@ -221,33 +166,34 @@ export default (async () => {return {
targets: 'dist/*'
}),
consts({
environment: build,
environment: appEnv,
buildinfo: getBuildInfo(),
nextcloudBaseURL: nextcloudBaseURL,
nextcloudBaseURL: config.nextcloudBaseURL,
}),
emitEJS({
src: 'assets',
include: ['**/*.ejs', '**/.*.ejs'],
data: {
getUrl: (p) => {
return url.resolve(basePath, p);
return url.resolve(config.basePath, p);
},
getPrivateUrl: (p) => {
return url.resolve(`${basePath}local/${pkg.name}/`, p);
return url.resolve(`${config.basePath}local/${pkg.name}/`, p);
},
name: pkg.name,
entryPointURL: entryPointURL,
nextcloudWebAppPasswordURL: nextcloudWebAppPasswordURL,
nextcloudWebDavURL: nextcloudWebDavURL,
nextcloudBaseURL: nextcloudBaseURL,
nextcloudFileURL: nextcloudFileURL,
nextcloudName: nextcloudName,
keyCloakServer: keyCloakServer,
keyCloakBaseURL: keyCloakBaseURL,
keyCloakClientId: keyCloakClientId,
pdfAsQualifiedlySigningServer: pdfAsQualifiedlySigningServer,
environment: build,
matomoSiteId: matomoSiteId,
entryPointURL: config.entryPointURL,
nextcloudWebAppPasswordURL: config.nextcloudWebAppPasswordURL,
nextcloudWebDavURL: config.nextcloudWebDavURL,
nextcloudBaseURL: config.nextcloudBaseURL,
nextcloudFileURL: config.nextcloudFileURL,
nextcloudName: config.nextcloudName,
keyCloakServer: config.keyCloakServer,
keyCloakBaseURL: config.keyCloakBaseURL,
keyCloakClientId: config.keyCloakClientId,
pdfAsQualifiedlySigningServer: config.pdfAsQualifiedlySigningServer,
environment: appEnv,
matomoUrl: config.matomoUrl,
matomoSiteId: config.matomoSiteId,
buildInfo: getBuildInfo()
}
}),
......@@ -287,9 +233,6 @@ Dependencies:
emitFiles: true,
fileName: 'shared/[name].[hash][extname]'
}),
replace({
"process.env.BUILD": '"' + build + '"',
}),
copy({
targets: [
{src: 'assets/silent-check-sso.html', dest:'dist'},
......@@ -334,10 +277,10 @@ Dependencies:
contentBase: '.',
host: '127.0.0.1',
port: 8001,
historyApiFallback: basePath + pkg.name + '.html',
historyApiFallback: config.basePath + pkg.name + '.html',
https: USE_HTTPS ? generateTLSConfig() : false,
headers: {
'Content-Security-Policy': `default-src 'self' 'unsafe-eval' 'unsafe-inline' analytics.tugraz.at ${keyCloakServer} ${entryPointURL} httpbin.org ${nextcloudBaseURL} www.handy-signatur.at ${pdfAsQualifiedlySigningServer} ; img-src * blob: data:`
'Content-Security-Policy': `default-src 'self' 'unsafe-eval' 'unsafe-inline' ${config.matomoUrl} ${config.keyCloakServer} ${config.entryPointURL} httpbin.org ${config.nextcloudOrigin} www.handy-signatur.at ${config.pdfAsQualifiedlySigningServer} ; img-src * blob: data:`
},
}) : false
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment