From 93d0bb8e5ecbb4e7c1a205f7171fb016b99db027 Mon Sep 17 00:00:00 2001 From: SteDev2 Date: Tue, 30 Jul 2024 16:53:14 +0200 Subject: [PATCH 1/2] Update and fix angularjs --- iam-login-service/pom.xml | 27 ++- .../src/main/webapp/WEB-INF/tags/iam/page.tag | 2 +- .../main/webapp/WEB-INF/tags/iamHeader.tag | 2 +- .../WEB-INF/views/iam/cern/register.jsp | 4 +- .../webapp/WEB-INF/views/iam/dashboard.jsp | 9 +- .../main/webapp/WEB-INF/views/iam/login.jsp | 46 +++-- .../webapp/WEB-INF/views/iam/register.jsp | 48 +++--- .../WEB-INF/views/iam/resetPassword.jsp | 4 +- .../WEB-INF/views/iam/samlDiscovery.jsp | 4 +- .../registration/registration.controller.js | 85 +++++----- .../webapp/resources/iam/js/iam-login-app.js | 78 ++++----- iam-test-client/pom.xml | 9 +- .../src/main/resources/templates/index.html | 158 +++++++++--------- pom.xml | 50 ++++-- 14 files changed, 282 insertions(+), 244 deletions(-) diff --git a/iam-login-service/pom.xml b/iam-login-service/pom.xml index 50380d9c8..1d3cae51c 100644 --- a/iam-login-service/pom.xml +++ b/iam-login-service/pom.xml @@ -106,7 +106,7 @@ - org.webjars + org.webjars.npm angular-ui-router @@ -116,27 +116,42 @@ - org.webjars + org.webjars.npm + angular-cookies + + + + org.webjars.npm + angular-resource + + + + org.webjars.npm + angular-animate + + + + org.webjars.npm angular-sanitize - org.webjars + org.webjars.npm jquery - org.webjars + org.webjars.npm jquery-ui - org.webjars + org.webjars.npm bootstrap - org.webjars + org.webjars.npm font-awesome diff --git a/iam-login-service/src/main/webapp/WEB-INF/tags/iam/page.tag b/iam-login-service/src/main/webapp/WEB-INF/tags/iam/page.tag index 76a81254e..4dfeb4708 100644 --- a/iam-login-service/src/main/webapp/WEB-INF/tags/iam/page.tag +++ b/iam-login-service/src/main/webapp/WEB-INF/tags/iam/page.tag @@ -25,7 +25,7 @@ + href="/webjars/bootstrap/dist/css/bootstrap.min.css"> + href="/webjars/bootstrap/dist/css/bootstrap.min.css"> - - + + diff --git a/iam-login-service/src/main/webapp/WEB-INF/views/iam/dashboard.jsp b/iam-login-service/src/main/webapp/WEB-INF/views/iam/dashboard.jsp index 03ca0827e..a9bf2d60d 100644 --- a/iam-login-service/src/main/webapp/WEB-INF/views/iam/dashboard.jsp +++ b/iam-login-service/src/main/webapp/WEB-INF/views/iam/dashboard.jsp @@ -51,13 +51,12 @@ - + - - - - + + + diff --git a/iam-login-service/src/main/webapp/WEB-INF/views/iam/login.jsp b/iam-login-service/src/main/webapp/WEB-INF/views/iam/login.jsp index 64934b085..29a91a90a 100644 --- a/iam-login-service/src/main/webapp/WEB-INF/views/iam/login.jsp +++ b/iam-login-service/src/main/webapp/WEB-INF/views/iam/login.jsp @@ -20,24 +20,16 @@ <%@ taglib prefix="t" tagdir="/WEB-INF/tags/iam"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> - + - + + angular.element(document).ready(function () { angular.bootstrap(document, ['passwordResetApp']); }); +
@@ -54,8 +46,8 @@
- - + +
${SPRING_SECURITY_LAST_EXCEPTION.message}
@@ -69,7 +61,7 @@

Welcome to ${iamOrganisationName} -

+
-
- You have been successfully authenticated as
- ${IAM_X509_CRED.subject} - -

- This certificate is not linked to any account in this organization -

-
+
+ You have been successfully authenticated as
+ ${IAM_X509_CRED.subject} + +

+ This certificate is not linked to any account in this organization +

+
-
- -
+
+ +
- + diff --git a/iam-login-service/src/main/webapp/WEB-INF/views/iam/register.jsp b/iam-login-service/src/main/webapp/WEB-INF/views/iam/register.jsp index ba6c36588..c8dd3226d 100644 --- a/iam-login-service/src/main/webapp/WEB-INF/views/iam/register.jsp +++ b/iam-login-service/src/main/webapp/WEB-INF/views/iam/register.jsp @@ -16,28 +16,28 @@ --%> <%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags"%> - <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - <%@ taglib prefix="t" tagdir="/WEB-INF/tags/iam"%> - <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="t" tagdir="/WEB-INF/tags/iam"%> +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> - - - - - - - - - - - - - - - -
-
-
-
-
-
\ No newline at end of file + + + + + + + + + + + + + + + +
+
+
+
+
+
\ No newline at end of file diff --git a/iam-login-service/src/main/webapp/WEB-INF/views/iam/resetPassword.jsp b/iam-login-service/src/main/webapp/WEB-INF/views/iam/resetPassword.jsp index 7e8c40f27..33cc42e8d 100644 --- a/iam-login-service/src/main/webapp/WEB-INF/views/iam/resetPassword.jsp +++ b/iam-login-service/src/main/webapp/WEB-INF/views/iam/resetPassword.jsp @@ -20,8 +20,8 @@ - - + + diff --git a/iam-login-service/src/main/webapp/WEB-INF/views/iam/samlDiscovery.jsp b/iam-login-service/src/main/webapp/WEB-INF/views/iam/samlDiscovery.jsp index 1c7b73e0e..18b28358d 100644 --- a/iam-login-service/src/main/webapp/WEB-INF/views/iam/samlDiscovery.jsp +++ b/iam-login-service/src/main/webapp/WEB-INF/views/iam/samlDiscovery.jsp @@ -24,8 +24,8 @@ - - + + diff --git a/iam-login-service/src/main/webapp/resources/iam/apps/registration/registration.controller.js b/iam-login-service/src/main/webapp/resources/iam/apps/registration/registration.controller.js index 18700df57..522363edc 100644 --- a/iam-login-service/src/main/webapp/resources/iam/apps/registration/registration.controller.js +++ b/iam-login-service/src/main/webapp/resources/iam/apps/registration/registration.controller.js @@ -16,7 +16,7 @@ 'use strict'; angular.module('registrationApp') - .controller('RegistrationController', RegistrationController); + .controller('RegistrationController', RegistrationController); RegistrationController.$inject = [ '$scope', '$q', '$window', '$cookies', 'RegistrationRequestService', @@ -24,8 +24,8 @@ RegistrationController.$inject = [ ]; function RegistrationController( - $scope, $q, $window, $cookies, RegistrationRequestService, AuthnInfo, Aup, - PrivacyPolicy) { + $scope, $q, $window, $cookies, RegistrationRequestService, AuthnInfo, Aup, + PrivacyPolicy) { var vm = this; var EXT_AUTHN_ROLE = 'ROLE_EXT_AUTH_UNREGISTERED'; @@ -57,44 +57,44 @@ function RegistrationController( function activate() { RegistrationRequestService.getConfig() - .then(function(res) { - $scope.config = res.data; - vm.resetRequest(); - vm.populateRequest(); - }) - .catch(function(err) { - console.error( - 'Error fetching registration config: ' + res.status + ' ' + - res.statusText); - }); + .then(function (res) { + $scope.config = res.data; + vm.resetRequest(); + vm.populateRequest(); + }) + .catch(function (err) { + console.error( + 'Error fetching registration config: ' + res.status + ' ' + + res.statusText); + }); Aup.getAup() - .then(function(res) { - if (res != null) { - $scope.aup = res.data; - } - }) - .catch(function(res) { - console.error( - 'Error getting AUP : ' + res.status + ' ' + res.statusText); - }); + .then(function (res) { + if (res != null) { + $scope.aup = res.data; + } + }) + .catch(function (res) { + console.error( + 'Error getting AUP : ' + res.status + ' ' + res.statusText); + }); PrivacyPolicy.getPrivacyPolicy() - .then(function(res) { - $scope.privacyPolicy = res; - }) - .catch(function(res) { - console.error( - 'Error fetching privacy policy: ' + res.status + ' ' + - res.statusText); - }); + .then(function (res) { + $scope.privacyPolicy = res; + }) + .catch(function (res) { + console.error( + 'Error fetching privacy policy: ' + res.status + ' ' + + res.statusText); + }); } function userIsExternallyAuthenticated() { return getUserAuthorities().indexOf(EXT_AUTHN_ROLE) > -1; } - function lookupAuthInfo(info, propertyName){ - if (typeof info[propertyName] != 'undefined'){ + function lookupAuthInfo(info, propertyName) { + if (typeof info[propertyName] != 'undefined') { return info[propertyName]; } else if (typeof info['additional_attributes'][propertyName] != 'undefined') { return info.additional_attributes[propertyName]; @@ -104,13 +104,13 @@ function RegistrationController( } function populateValue(info, name) { - if (typeof $scope.config.fields != 'undefined' && typeof $scope.config.fields[name] != 'undefined' && typeof $scope.config.fields[name].externalAuthAttribute != 'undefined'){ + if (typeof $scope.config.fields != 'undefined' && typeof $scope.config.fields[name] != 'undefined' && typeof $scope.config.fields[name].externalAuthAttribute != 'undefined') { return lookupAuthInfo(info, $scope.config.fields[name].externalAuthAttribute); } } function populateRequest() { - var success = function(res) { + var success = function (res) { var info = res.data; $scope.extAuthInfo = info; $scope.request = { @@ -127,12 +127,12 @@ function RegistrationController( $scope.extAuthProviderName = 'a SAML identity provider'; } - angular.forEach($scope.registrationForm.$error.required, function(field) { + angular.forEach($scope.registrationForm.$error.required, function (field) { field.$setDirty(); }); }; - var error = function(err) { + var error = function (err) { $scope.operationResult = 'err'; $scope.textAlert = err.data.error_description || err.data.detail; $scope.busy = false; @@ -147,18 +147,18 @@ function RegistrationController( } function createRequest() { - var success = function(res) { + var success = function (res) { $window.location.href = '/registration/submitted'; }; - var error = function(err) { + var error = function (err) { $scope.operationResult = 'err'; $scope.textAlert = err.data.error; $scope.busy = false; }; RegistrationRequestService.createRequest($scope.request) - .then(success, error); + .then(success, error); } function submit() { @@ -188,16 +188,19 @@ function RegistrationController( function fieldValid(name) { return $scope.registrationForm[name].$dirty && - $scope.registrationForm[name].$valid; + $scope.registrationForm[name].$valid; } function fieldInvalid(name) { return $scope.registrationForm[name].$dirty && - $scope.registrationForm[name].$invalid; + $scope.registrationForm[name].$invalid; } function fieldReadonly(name) { if ($scope.config) { + if (!$scope.config.fields) { + return false; + } var field = $scope.config.fields[name]; return field.readOnly === true; } diff --git a/iam-login-service/src/main/webapp/resources/iam/js/iam-login-app.js b/iam-login-service/src/main/webapp/resources/iam/js/iam-login-app.js index 947795799..b8a6c3184 100644 --- a/iam-login-service/src/main/webapp/resources/iam/js/iam-login-app.js +++ b/iam-login-service/src/main/webapp/resources/iam/js/iam-login-app.js @@ -13,54 +13,54 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -(function() { +(function () { 'use strict'; angular.module('iam-login-app', ['ui.bootstrap']) - .controller( - 'idp-selection', - [ - '$scope', '$http', '$uibModalInstance', '$log', '$window', - '$timeout', - function($scope, $http, $uibModalInstance, $log, $window, $timeout) { + .controller( + 'idp-selection', + [ + '$scope', '$http', '$uibModalInstance', '$log', '$window', + '$timeout', + function ($scope, $http, $uibModalInstance, $log, $window, $timeout) { - $scope.ok = function() { - $window.location.href = - '/saml/login?idp=' + $scope.idpSelected.entityId; - }; - - $scope.cancel = function() { $uibModalInstance.close(); }; + $scope.ok = function () { + $window.location.href = + '/saml/login?idp=' + $scope.idpSelected.entityId; + }; - $scope.reset = function(){ - $scope.idpSelected = null; - $timeout(function(){ - $window.document.getElementById("idp-selection-input").focus(); - },0); - }; + $scope.cancel = function () { $uibModalInstance.close(); }; - $scope.lookupIdp = function(val) { + $scope.reset = function () { + $scope.idpSelected = null; + $timeout(function () { + $window.document.getElementById("idp-selection-input").focus(); + }, 0); + }; - var result = - $http.get('/saml/idps', {params: {q: val}}) - .then(function(response) { return response.data; }); + $scope.lookupIdp = function (val) { - return result; - }; - } - ]) - .controller('idp-selection-modal-ctrl', [ - '$scope', '$uibModal', - function($scope, $uibModal) { + var result = + $http.get('/saml/idps', { params: { q: val } }) + .then(function (response) { return response.data; }); - $scope.open = function() { - $uibModal.open({ - templateUrl: - '/resources/iam/template/idpSelectionModalContent.html', - controller: 'idp-selection', - size: 'lg', - animation: true - }); + return result; }; } - ]); + ]) + .controller('idp-selection-modal-ctrl', [ + '$scope', '$uibModal', + function ($scope, $uibModal) { + + $scope.open = function () { + $uibModal.open({ + templateUrl: + '/resources/iam/template/idpSelectionModalContent.html', + controller: 'idp-selection', + size: 'lg', + animation: true + }); + }; + } + ]); })(); \ No newline at end of file diff --git a/iam-test-client/pom.xml b/iam-test-client/pom.xml index a727bb31d..f1a86809e 100644 --- a/iam-test-client/pom.xml +++ b/iam-test-client/pom.xml @@ -22,15 +22,20 @@ - org.webjars + org.webjars.npm jquery - org.webjars + org.webjars.npm bootstrap + + org.webjars.bower + angular-jwt + + org.webjars webjars-locator-core diff --git a/iam-test-client/src/main/resources/templates/index.html b/iam-test-client/src/main/resources/templates/index.html index b1c437fdd..5882f73cd 100644 --- a/iam-test-client/src/main/resources/templates/index.html +++ b/iam-test-client/src/main/resources/templates/index.html @@ -8,10 +8,83 @@ - - - + + + + + +