From e4136fff5f7266e2c8d8981f15b901c9081b1bb2 Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Thu, 9 Nov 2023 09:38:47 +0100 Subject: [PATCH 1/5] [Fix] Add auth-related variables into Docker environment substitution. AND DOCUMENT THE PROCESS!!! --- .docker/docker-entrypoint.sh | 2 +- doc/development.md | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.docker/docker-entrypoint.sh b/.docker/docker-entrypoint.sh index 479eee6b..32dd4772 100755 --- a/.docker/docker-entrypoint.sh +++ b/.docker/docker-entrypoint.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh set -eu -envsubst '${API_URL} ${APP_TITLE} ${LANGUAGE} ${NAVIGATOR_LANGUAGE} ${BASENAME} ${EXTENSIONS}' < /etc/nginx/config.js.template > /var/www/config.js +envsubst '${API_URL} ${APP_TITLE} ${LANGUAGE} ${NAVIGATOR_LANGUAGE} ${BASENAME} ${EXTENSIONS} ${AUTHENTICATION} ${AUTH_SERVER_URL} ${AUTH_CLIENT_ID}' < /etc/nginx/config.js.template > /var/www/config.js cp /etc/nginx/index.html.template /var/www/index.html sed -i "s|%RECORD_MANAGER_BASENAME%|${BASENAME}|g" /var/www/index.html diff --git a/doc/development.md b/doc/development.md index 935b39da..3bf06c72 100644 --- a/doc/development.md +++ b/doc/development.md @@ -6,4 +6,13 @@ This file contains info for contributors to the Record Manager UI codebase. To configure the application use [Setup Guide](./setup.md). To run application in development mode use `npm run dev`. -By default, the application is accessible from http://localhost:3000. \ No newline at end of file +By default, the application is accessible from http://localhost:3000. + +## Add Configuration Parameters + +When runtime configuration parameters are added to the application, they also need to be added to Docker processing so +that environment variables can be used to set the variables. The following needs to be done: + +1. Add the parameters to `.docker/config.js.template` +2. Add the parameters to environment substitution in `.docker/docker-entrypoint.sh` +3. Add the parameters to `.env.example` From edf3731f69c7d4cc3a0c09688b952993736c38ef Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Thu, 9 Nov 2023 11:03:14 +0100 Subject: [PATCH 2/5] [OIDC] Allow listing users, but prevent editing them when using OIDC. --- js/components/user/UserRow.js | 17 ++++++++++------- js/components/user/UserTable.js | 5 ++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/js/components/user/UserRow.js b/js/components/user/UserRow.js index 736b445a..46b00ee6 100644 --- a/js/components/user/UserRow.js +++ b/js/components/user/UserRow.js @@ -4,6 +4,7 @@ import withI18n from "../../i18n/withI18n"; import {Button} from "react-bootstrap"; import {LoaderSmall} from "../Loader"; import PropTypes from "prop-types"; +import IfInternalAuth from "../misc/oidc/IfInternalAuth"; let UserRow = (props) => { const user = props.user; @@ -17,13 +18,15 @@ let UserRow = (props) => { {user.username} {user.institution ? user.institution.name : ''} {user.emailAddress} - - - - + + + + + + ; }; diff --git a/js/components/user/UserTable.js b/js/components/user/UserTable.js index bb8f6966..2080e084 100644 --- a/js/components/user/UserTable.js +++ b/js/components/user/UserTable.js @@ -8,6 +8,7 @@ import withI18n from "../../i18n/withI18n"; import UserRow from "./UserRow"; import {ACTION_STATUS} from "../../constants/DefaultConstants"; import PropTypes from "prop-types"; +import IfInternalAuth from "../misc/oidc/IfInternalAuth"; class UserTable extends React.Component { static propTypes = { @@ -68,7 +69,9 @@ class UserTable extends React.Component { {this.i18n('login.username')} {this.i18n('institution.name')} {this.i18n('users.email')} - {this.i18n('actions')} + + {this.i18n('actions')} + ; } From 2f3ece59ec38103a520a0382160686dae8dfbe4b Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Thu, 9 Nov 2023 11:12:13 +0100 Subject: [PATCH 3/5] [OIDC] Prevent adding users when using OIDC. --- js/components/user/Users.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/js/components/user/Users.js b/js/components/user/Users.js index 03b00252..c2f72df8 100644 --- a/js/components/user/Users.js +++ b/js/components/user/Users.js @@ -9,6 +9,7 @@ import {ACTION_STATUS, ALERT_TYPES} from "../../constants/DefaultConstants"; import AlertMessage from "../AlertMessage"; import {LoaderCard, LoaderSmall} from "../Loader"; import PropTypes from "prop-types"; +import IfInternalAuth from "../misc/oidc/IfInternalAuth"; class Users extends React.Component { static propTypes = { @@ -38,15 +39,17 @@ class Users extends React.Component { -
- -
+ +
+ +
+
{showAlert && userDeleted.status === ACTION_STATUS.ERROR && - } + } {showAlert && userDeleted.status === ACTION_STATUS.SUCCESS && - } + }
; } From 3a8a6f1d53f2b17d7ff5e207ba7a3cf3dd2781e6 Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Mon, 13 Nov 2023 08:36:33 +0100 Subject: [PATCH 4/5] [OIDC] Use basename when resolving URL for OIDC signing redirect. --- js/utils/OidcUtils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/utils/OidcUtils.js b/js/utils/OidcUtils.js index 33fdb3c8..f98396f8 100644 --- a/js/utils/OidcUtils.js +++ b/js/utils/OidcUtils.js @@ -48,7 +48,12 @@ export const getOidcConfig = () => { function resolveUrl() { const loc = window.location; - return loc.protocol + "//" + loc.host + loc.pathname; + let url = loc.protocol + "//" + loc.host; + const basename = getEnv("BASENAME"); + if (basename !== "/" && basename !== "./") { + url += basename; + } + return url; } export const userProfileLink = () => { From 7df0d22bd90c9a66746a562b7220a7cb56222dfb Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Mon, 13 Nov 2023 08:41:19 +0100 Subject: [PATCH 5/5] [Fix] Fix history timestamp parsing. The timestamp parsing was wrong, causing all history records to appear as being created at epoch. --- js/utils/Utils.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/js/utils/Utils.js b/js/utils/Utils.js index fd79f448..60e36708 100644 --- a/js/utils/Utils.js +++ b/js/utils/Utils.js @@ -1,9 +1,9 @@ 'use strict'; import Bowser from 'bowser'; import * as Constants from "../constants/DefaultConstants"; +import {ROLE} from "../constants/DefaultConstants"; import * as Vocabulary from "../constants/Vocabulary"; import * as supportedDevices from "../constants/SupportedDevices"; -import {ROLE} from "../constants/DefaultConstants"; /** * Common propositions that should not be capitalized @@ -274,13 +274,11 @@ export function deviceIsSupported() { // format to DD-MM-YYYY HH:mm:ss:SSS export function formatDateWithMilliseconds(timestamp) { - const date = new Date(timestamp / 1000); - const dateStr = - ("00" + date.getDate()).slice(-2) + "-" + + const date = new Date(timestamp); + return ("00" + date.getDate()).slice(-2) + "-" + ("00" + (date.getMonth() + 1)).slice(-2) + "-" + date.getFullYear() + " " + ("00" + date.getHours()).slice(-2) + ":" + ("00" + date.getMinutes()).slice(-2) + ":" + ("00" + date.getSeconds()).slice(-2) + ("00" + date.getMilliseconds()).slice(-2); - return dateStr; } \ No newline at end of file