diff --git a/VERSION b/VERSION index 07192b5..a53ac2f 100644 --- a/VERSION +++ b/VERSION @@ -5,6 +5,6 @@ # tags with and without build number so operators use the versioned # tag but we always keep a timestamped tag in case a semantic tag gets # replaced accidentally -VER=0.2.1 +VER=0.2.2 TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")" unset VER diff --git a/public/dev/js/science_portal_session.js b/public/dev/js/science_portal_session.js index eb3c285..c2beaf4 100644 --- a/public/dev/js/science_portal_session.js +++ b/public/dev/js/science_portal_session.js @@ -304,6 +304,10 @@ return parseFloat(matches.map(m => m[1])[0]).toFixed(2) } + function zeroPrefix(value) { + return ("0" + value).slice(-2) + } + function loadPlatformUsage(refreshHandler) { var statsURL = _selfPortalSess.sessionServiceURL + "?view=stats" Promise.resolve(_getAjaxData(statsURL, {})) @@ -312,8 +316,8 @@ var nowDate = new Date() var month = nowDate.getUTCMonth() + 1 _selfPortalSess._platformUsage.updated = nowDate.getUTCFullYear() + "-" - + ("0" + month).slice(-2) + "-" + ("0" + nowDate.getUTCDate()).slice(-2) - + " " + nowDate.getUTCHours() + ":" + nowDate.getMinutes() + + zeroPrefix(month) + "-" + zeroPrefix(nowDate.getUTCDate()) + + " " + zeroPrefix(nowDate.getUTCHours()) + ":" + zeroPrefix(nowDate.getMinutes()) _selfPortalSess._platformUsage.cpu = { "used" : platformUsage.cores.requestedCPUCores, diff --git a/public/index.html b/public/index.html index 95fc5b1..bcfcafb 100644 --- a/public/index.html +++ b/public/index.html @@ -2,7 +2,6 @@ - -
New Session Help
+
New Session Help
{ this.state.pageState.spForm.progressBar.animated === true && } { this.state.pageState.spForm.progressBar.animated === false && } diff --git a/src/main/java/org/opencadc/scienceportal/SciencePortalAuthAction.java b/src/main/java/org/opencadc/scienceportal/SciencePortalAuthAction.java index d53dd6c..da69924 100644 --- a/src/main/java/org/opencadc/scienceportal/SciencePortalAuthAction.java +++ b/src/main/java/org/opencadc/scienceportal/SciencePortalAuthAction.java @@ -75,6 +75,8 @@ import ca.nrc.cadc.rest.InlineContentHandler; import ca.nrc.cadc.rest.RestAction; import ca.nrc.cadc.util.StringUtil; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.opencadc.token.Client; import javax.security.auth.Subject; @@ -82,6 +84,7 @@ import java.net.URI; import java.util.Arrays; import java.util.Collections; +import java.util.NoSuchElementException; /** * Base class to support storing the OIDC Access Token in a cookie. @@ -93,6 +96,8 @@ * TODO: jenkinsd 2023.10.20 */ public abstract class SciencePortalAuthAction extends RestAction { + private static final Logger LOGGER = LogManager.getLogger(SciencePortalAuthAction.class); + protected final ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration(); protected Client getOIDCClient() throws IOException { @@ -116,15 +121,20 @@ protected Subject getCurrentSubject() throws Exception { // Only split on the first "=" symbol, and trim any wrapping double quotes final String encryptedCookieValue = cookie.split("=", 2)[1].replaceAll("\"", ""); - final String accessToken = getOIDCClient().getAccessToken(encryptedCookieValue); - subject.getPrincipals().add(new AuthorizationTokenPrincipal(AuthenticationUtil.AUTHORIZATION_HEADER, - AuthenticationUtil.CHALLENGE_TYPE_BEARER - + " " + accessToken)); - subject.getPublicCredentials().add( - new AuthorizationToken(AuthenticationUtil.CHALLENGE_TYPE_BEARER, accessToken, - Collections.singletonList( - URI.create(syncInput.getRequestURI()).getHost()))); + try { + final String accessToken = getOIDCClient().getAccessToken(encryptedCookieValue); + + subject.getPrincipals().add(new AuthorizationTokenPrincipal(AuthenticationUtil.AUTHORIZATION_HEADER, + AuthenticationUtil.CHALLENGE_TYPE_BEARER + + " " + accessToken)); + subject.getPublicCredentials().add( + new AuthorizationToken(AuthenticationUtil.CHALLENGE_TYPE_BEARER, accessToken, + Collections.singletonList( + URI.create(syncInput.getRequestURI()).getHost()))); + } catch (NoSuchElementException noTokenForKeyInCacheException) { + LOGGER.warn("Cookie found and decrypted but no value in cache. Ignoring cookie..."); + } } if (!subject.getPrincipals(AuthorizationTokenPrincipal.class).isEmpty()) { diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 87fa16d..1ba628a 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -8,6 +8,7 @@ final ApplicationConfiguration configuration = new ApplicationConfiguration(); final String sessionsResourceID = configuration.getResourceID(); final String sessionsStandardID = configuration.getStandardID(); + final String themeName = configuration.getThemeName(); String bannerText = configuration.getBannerMessage(); String headerURLJSON = configuration.getHeaderURLs().toString(); @@ -46,9 +47,11 @@ + <% if ("canfar".equals(themeName)) { %> + <% } %> @@ -99,10 +102,9 @@ baseURL: window.location.origin, sessionsResourceID: '<%= sessionsResourceID %>', sessionsStandardID: '<%= sessionsStandardID %>', - themeName: '<%= configuration.getThemeName() %>', + themeName: '<%= themeName %>', bannerText: '<%= bannerText %>', contentBase: "${contextPath}/dist", - themeName: '<%= configuration.getThemeName() %>', headerURLs: JSON.parse('<%= headerURLJSON %>') }) diff --git a/src/react/canfar/CanfarLoginModal.js b/src/react/canfar/CanfarLoginModal.js index 98cd6de..cd7ee51 100644 --- a/src/react/canfar/CanfarLoginModal.js +++ b/src/react/canfar/CanfarLoginModal.js @@ -69,7 +69,7 @@ class CanfarLoginModal extends React.Component { {errMsg} + tabIndex="5" title="Forgot Password"> Forgot your Account information?
Authentication required - Sign In to OpenID Connect + Sign In to OpenID Connect diff --git a/src/react/src/SRCNavbar.js b/src/react/src/SRCNavbar.js index 3552774..8f126c9 100644 --- a/src/react/src/SRCNavbar.js +++ b/src/react/src/SRCNavbar.js @@ -35,7 +35,7 @@ class SRCNavbar extends React.Component { {this.state.isAuthenticated === true && - {this.state.authenticatedUser} + {this.state.authenticatedUser} }