NIFI-655: - Adding automatic client side token renewal. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/749f4e9b Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/749f4e9b Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/749f4e9b
Branch: refs/heads/NIFI-655 Commit: 749f4e9be16e63b27c35052c0535546ad9853341 Parents: 06cb7cf Author: Matt Gilman <[email protected]> Authored: Fri Nov 13 16:19:05 2015 -0500 Committer: Matt Gilman <[email protected]> Committed: Fri Nov 13 16:19:05 2015 -0500 ---------------------------------------------------------------------- .../webapp/WEB-INF/pages/bulletin-board.jsp | 1 + .../src/main/webapp/WEB-INF/pages/canvas.jsp | 1 + .../src/main/webapp/WEB-INF/pages/cluster.jsp | 1 + .../src/main/webapp/WEB-INF/pages/counters.jsp | 1 + .../src/main/webapp/WEB-INF/pages/history.jsp | 1 + .../main/webapp/WEB-INF/pages/provenance.jsp | 1 + .../src/main/webapp/WEB-INF/pages/summary.jsp | 1 + .../src/main/webapp/WEB-INF/pages/templates.jsp | 1 + .../src/main/webapp/WEB-INF/pages/users.jsp | 1 + .../src/main/webapp/js/nf/login/nf-login.js | 45 +- .../src/main/webapp/js/nf/nf-common.js | 1875 +++++++++--------- .../src/main/webapp/js/nf/nf-storage.js | 100 +- 12 files changed, 1084 insertions(+), 945 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp index 6df0e51..3eaa225 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp @@ -28,6 +28,7 @@ <link rel="stylesheet" href="js/jquery/qtip2/jquery.qtip.min.css?" type="text/css" /> <link rel="stylesheet" href="js/jquery/ui-smoothness/jquery-ui-1.10.4.min.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp index dcfb47b..55c2b86 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp @@ -40,6 +40,7 @@ <script type="text/javascript" src="js/codemirror/lib/codemirror-compressed.js"></script> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/jquery/ui-smoothness/jquery-ui-1.10.4.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/jquery.ellipsis.js"></script> <script type="text/javascript" src="js/jquery/jquery.each.js"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp index 55ffabe..acf2e55 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp @@ -30,6 +30,7 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp index 7362cf2..e3113f9 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp @@ -30,6 +30,7 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp index 935512a..ac28bb7 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp @@ -30,6 +30,7 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp index e02a7cd..496bfd1 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp @@ -31,6 +31,7 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/modal/jquery.modal.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/tabbs/jquery.tabbs.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp index e6f3305..45dff93 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp @@ -38,6 +38,7 @@ <script type="text/javascript" src="js/codemirror/lib/codemirror-compressed.js"></script> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/jquery/ui-smoothness/jquery-ui-1.10.4.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/tabbs/jquery.tabbs.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp index 126c388..452064d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp @@ -30,6 +30,7 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/jquery.form.min.js"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp index a5f422c..b3e0968 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp @@ -31,6 +31,7 @@ <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css" type="text/css" /> <script type="text/javascript" src="js/jquery/jquery-2.1.1.min.js"></script> + <script type="text/javascript" src="js/jquery/jquery.base64.js"></script> <script type="text/javascript" src="js/jquery/jquery.center.js"></script> <script type="text/javascript" src="js/jquery/tabbs/jquery.tabbs.js?${project.version}"></script> <script type="text/javascript" src="js/jquery/combo/jquery.combo.js?${project.version}"></script> http://git-wip-us.apache.org/repos/asf/nifi/blob/749f4e9b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js index f844d91..9e1dab6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js @@ -98,7 +98,7 @@ nf.Login = (function () { } }).done(function (jwt) { // store the jwt and reload the page - nf.Storage.setItem('jwt', jwt); + nf.Storage.setItem('jwt', jwt, nf.Common.getJwtExpiration(jwt)); // check to see if they actually have access now $.ajax({ @@ -109,15 +109,18 @@ nf.Login = (function () { if (response.identity === 'anonymous') { showLogoutLink(); + // schedule automatic token refresh + nf.Common.scheduleTokenRefresh(); + // show the user - var user = getJwtSubject(jwt); + var user = nf.Common.getJwtSubject(jwt); $('#nifi-user-submit-justification').text(user); // show the registration form initializeNiFiRegistration(); showNiFiRegistration(); } else { - // reload as appropriate + // reload as appropriate - no need to schedule token refresh as the page is reloading if (top !== window) { parent.window.location = '/nifi'; } else { @@ -127,8 +130,11 @@ nf.Login = (function () { }).fail(function (xhr, status, error) { showLogoutLink(); + // schedule automatic token refresh + nf.Common.scheduleTokenRefresh(); + // show the user - var user = getJwtSubject(jwt); + var user = nf.Common.getJwtSubject(jwt); $('#nifi-user-submit-justification').text(user); if (xhr.status === 401) { @@ -189,33 +195,6 @@ nf.Login = (function () { }); }; - /** - * Extracts the subject from the specified jwt. If the jwt is not as expected - * an empty string is returned. - * - * @param {string} jwt - * @returns {string} - */ - var getJwtSubject = function (jwt) { - if (nf.Common.isDefinedAndNotNull(jwt)) { - var segments = jwt.split(/\./); - if (segments.length !== 3) { - return ''; - } - - var rawPayload = $.base64.atob(segments[1]); - var payload = JSON.parse(rawPayload); - - if (nf.Common.isDefinedAndNotNull(payload['preferred_username'])) { - return payload['preferred_username']; - } else { - ''; - } - } - - return ''; - }; - var logout = function () { nf.Storage.removeItem('jwt'); }; @@ -272,7 +251,7 @@ nf.Login = (function () { $('#login-message').text('Your account is active and you are already logged in.'); }).fail(function (xhr, status, error) { if (xhr.status === 401) { - var user = getJwtSubject(jwt); + var user = nf.Common.getJwtSubject(jwt); // show the user $('#nifi-user-submit-justification').text(user); @@ -316,7 +295,7 @@ nf.Login = (function () { if (xhr.status === 401) { // attempt to get a token for the current user without passing login credentials token.done(function (jwt) { - var user = getJwtSubject(jwt); + var user = nf.Common.getJwtSubject(jwt); // show the user $('#nifi-user-submit-justification').text(user);
