Skip to content

Commit

Permalink
Fixed keycloak redirect + speedtest issues
Browse files Browse the repository at this point in the history
  • Loading branch information
simensma-fresh committed Nov 9, 2023
1 parent 2c8e3e0 commit f76e456
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 29 deletions.
10 changes: 10 additions & 0 deletions services/minespace-web/public/silent-check-sso.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>

<body>
<script>
parent.postMessage(location.href, location.origin);
</script>
</body>

</html>
5 changes: 4 additions & 1 deletion services/minespace-web/runner/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ app.use(
})
);


const staticServe = expressStaticGzip(`${__dirname}/${BUILD_DIR}`, {
enableBrotli: true,
maxAge: "1y",
Expand Down Expand Up @@ -73,4 +74,6 @@ app.use(`${BASE_PATH}*`, staticServe);
app.use(`/`, staticServe);
app.use(`*`, staticServe);

app.listen(PORT, "0.0.0.0", () => console.log("Server running"));
const server = app.listen(PORT, "0.0.0.0", () => console.log("Server running"));
server.keepAliveTimeout = 10;
server.headersTimeout = 15;
2 changes: 1 addition & 1 deletion services/minespace-web/src/components/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Header = (props) => {
<div className="header-content">
<div>
<a className="header-logo" href="https://gov.bc.ca/">
<img alt="BC Government Logo" src={BC_GOV} width={154} />
<img alt="BC Government Logo" src={BC_GOV} width={154} height={43} />
</a>
<Link className="header-title" to={routes.HOME.route}>
MineSpace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
AjaxRequestSettingsModel,
} from "@syncfusion/ej2-react-pdfviewer";


interface PdfViewerProps {
pdfViewerServiceUrl: string;
documentPath: string;
Expand Down
6 changes: 5 additions & 1 deletion services/minespace-web/src/keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { KEYCLOAK } from "@mds/common";
const keycloak = new Keycloak(KEYCLOAK);
export const keycloakInitConfig = {
pkceMethod: KEYCLOAK.pkceMethod,
checkLoginIframe: false,

// Perform a silent sso check to determine whether the user is logged in or not.
// https://www.keycloak.org/docs/latest/securing_apps/index.html#using-the-adapter
onLoad: 'check-sso',
silentCheckSsoRedirectUri: `${location.origin}/silent-check-sso.html`
};

export default keycloak;
3 changes: 2 additions & 1 deletion services/minespace-web/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ASSET_PATH = process.env.ASSET_PATH || "/";
const BUILD_DIR = process.env.BUILD_DIR || "build";
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const MomentTimezoneDataPlugin = require('moment-timezone-data-webpack-plugin');
const CopyWebpackPlugin = require("copy-webpack-plugin");

// const smp = new SpeedMeasurePlugin({
// disable: !process.env.MEASURE_SPEED,
Expand All @@ -37,7 +38,7 @@ const PATHS = {
};

const BUILD_FILE_NAMES = {
css: "style/[name].css",
css: "style/[name].[contenthash:4].css",
bundle: "js/bundle.[chunkhash:4].js",
vendor: "js/[id].[chunkhash:4].js",
assets: "assets/[name].[hash:4].[ext]",
Expand Down
47 changes: 23 additions & 24 deletions services/minespace-web/webpack.parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const TerserPlugin = require("terser-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
const { EsbuildPlugin } = require('esbuild-loader');
const { EsbuildPlugin } = require("esbuild-loader");

const { WebpackManifestPlugin } = require("webpack-manifest-plugin");

Expand All @@ -19,13 +19,13 @@ const postCSSLoader = {
options: {
postcssOptions: {
plugins: () => [autoprefixer],
}
},
},
};

exports.devServer = ({ host, port } = {}) => ({
cache: {
type: 'filesystem'
type: "filesystem",
},
stats: "errors-only",
devServer: {
Expand All @@ -41,7 +41,7 @@ exports.devServer = ({ host, port } = {}) => ({
errors: false,
warnings: false,
},
}
},
},
});

Expand All @@ -52,23 +52,23 @@ exports.loadJS = ({ include, exclude } = {}) => ({
test: /\.[[t]sx?$/,
include,
exclude,
loader: 'esbuild-loader',
loader: "esbuild-loader",
options: {
target: 'es2016'
}
target: "es2016",
},
},
{
test: /\.[[j]sx?$/,
include,
exclude,

loader: 'esbuild-loader',
loader: "esbuild-loader",
options: {
/// Treat .js files as `.jsx` files
loader: 'jsx',
target: 'es2016'
}
}
loader: "jsx",
target: "es2016",
},
},
],
},
});
Expand All @@ -81,10 +81,10 @@ exports.loadTS = ({ include, exclude } = {}) => ({
include,
exclude,

loader: 'esbuild-loader',
loader: "esbuild-loader",
options: {
target: 'es2016'
}
target: "es2016",
},
},
],
},
Expand Down Expand Up @@ -416,22 +416,19 @@ exports.generateSourceMaps = ({ type } = {}) => ({
exports.bundleOptimization = ({ options, cssOptions } = {}) => ({
optimization: {
runtimeChunk: {
name: 'manifest'
name: "manifest",
},
splitChunks: options,
minimize: true,
minimizer: [
new EsbuildPlugin({
target: 'es2016'
target: "es2016",
}),
new CssMinimizerPlugin({
minimizerOptions: {
preset: [
'default',
cssOptions
]
}
})
preset: ["default", cssOptions],
},
}),
],
},
});
Expand Down Expand Up @@ -467,7 +464,9 @@ exports.clean = () => ({
});

exports.copy = (from, to) => ({
plugins: [new CopyWebpackPlugin({ patterns: [{ from, to, globOptions: { ignore: ["*.html"] } }] })],
plugins: [
new CopyWebpackPlugin({ patterns: [{ from, to, globOptions: { ignore: ["**/index.html"] } }] }),
],
});

exports.extractManifest = () => ({
Expand Down

0 comments on commit f76e456

Please sign in to comment.