This is an automated email from the ASF dual-hosted git repository.
thenatog pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 4ccb2b6 NIFI-9049 Replaced localStorage with sessionStorage for
Bearer Token
4ccb2b6 is described below
commit 4ccb2b6b4acc83fb86b7021ddadcadade6043490
Author: exceptionfactory <[email protected]>
AuthorDate: Tue Aug 24 16:39:14 2021 -0500
NIFI-9049 Replaced localStorage with sessionStorage for Bearer Token
- Added JavaScript Authorization Storage component for storing and
retrieving JSON Web Tokens
- Added access status request to remove Session Cookie when Token not found
NIFI-9049 Updated Jolt JavaScript application to use AuthorizationStorage
Signed-off-by: Nathan Gough <[email protected]>
This closes #5344.
---
.../org/apache/nifi/web/api/AccessResource.java | 8 ++-
.../src/main/webapp/WEB-INF/jsp/header.jsp | 1 +
.../nifi-framework/nifi-web/nifi-web-ui/pom.xml | 12 ++++
.../resources/filters/bulletin-board.properties | 1 +
.../src/main/resources/filters/canvas.properties | 1 +
.../src/main/resources/filters/cluster.properties | 1 +
.../src/main/resources/filters/counters.properties | 1 +
.../src/main/resources/filters/history.properties | 1 +
.../src/main/resources/filters/login.properties | 1 +
.../src/main/resources/filters/logout.properties | 1 +
.../main/resources/filters/provenance.properties | 1 +
.../src/main/resources/filters/summary.properties | 1 +
.../main/resources/filters/templates.properties | 1 +
.../src/main/resources/filters/users.properties | 1 +
.../src/main/webapp/js/nf/canvas/nf-canvas.js | 37 ++++++++----
.../src/main/webapp/js/nf/login/nf-login.js | 14 ++---
.../src/main/webapp/js/nf/nf-ajax-setup.js | 16 ++---
.../main/webapp/js/nf/nf-authorization-storage.js | 70 ++++++++++++++++++++++
.../nifi-web-ui/src/main/webapp/js/nf/nf-common.js | 25 ++++----
.../src/main/webapp/WEB-INF/jsp/index.jsp | 1 +
.../src/main/webapp/app/app.js | 4 +-
.../src/main/webapp/WEB-INF/jsp/worksheet.jsp | 1 +
22 files changed, 160 insertions(+), 40 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/AccessResource.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/AccessResource.java
index 7d37947..645d679 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/AccessResource.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/AccessResource.java
@@ -75,6 +75,7 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
@@ -253,7 +254,12 @@ public class AccessResource extends ApplicationResource {
// if there is no authorization header, we don't know the user
if (bearerToken == null) {
accessStatus.setStatus(AccessStatusDTO.Status.UNKNOWN.name());
- accessStatus.setMessage("No credentials supplied, unknown
user.");
+ accessStatus.setMessage("Access Unknown: Token not
found.");
+ } else if
(httpServletRequest.getHeader(HttpHeaders.AUTHORIZATION) == null) {
+
accessStatus.setStatus(AccessStatusDTO.Status.UNKNOWN.name());
+ accessStatus.setMessage("Access Unknown: Authorization
Header not found.");
+ // Remove Session Cookie when Authorization Header not
found
+ removeCookie(httpServletResponse,
SecurityCookieName.AUTHORIZATION_BEARER.getName());
} else {
try {
// authenticate the token
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/webapp/WEB-INF/jsp/header.jsp
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/webapp/WEB-INF/jsp/header.jsp
index f7dbd66..8a092c2 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/webapp/WEB-INF/jsp/header.jsp
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/webapp/WEB-INF/jsp/header.jsp
@@ -35,6 +35,7 @@
<script type="text/javascript"
src="../nifi/js/jquery/combo/jquery.combo.js"></script>
<script type="text/javascript"
src="../nifi/js/jquery/modal/jquery.modal.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-namespace.js"></script>
+ <script type="text/javascript"
src="../nifi/js/nf/nf-authorization-storage.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-storage.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-ajax-setup.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-universal-capture.js"></script>
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
index af8bff2..e927043 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml
@@ -486,6 +486,7 @@
<include>${staging.dir}/js/nf/nf-ng-bridge.js</include>
<include>${staging.dir}/js/nf/nf-ng-service-provider.js</include>
<include>${staging.dir}/js/nf/nf-cluster-summary.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-ajax-setup.js</include>
<include>${staging.dir}/js/nf/nf-universal-capture.js</include>
@@ -568,6 +569,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/history/nf-history-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -584,6 +586,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/provenance/nf-provenance-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -602,6 +605,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/summary/nf-summary-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -629,6 +633,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/counters/nf-counters-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -644,6 +649,7 @@
<includes>
<include>${staging.dir}/js/nf/nf-client.js</include>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -658,6 +664,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/templates/nf-templates-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -672,6 +679,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/cluster/nf-cluster-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -686,6 +694,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/bulletin-board/nf-bulletin-board-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -703,6 +712,7 @@
<output>${project.build.directory}/${project.build.finalName}/js/nf/login/nf-login-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
+
<include>${staging.dir}/js/nf/nf-authorization-storage.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
@@ -925,6 +935,8 @@
js/nf/canvas/nf-ng-canvas-namespace.js.gz,
js/nf/nf-universal-capture.js,
js/nf/nf-universal-capture.js.gz,
+ js/nf/nf-authorization-storage.js,
+ js/nf/nf-authorization-storage.js.gz,
js/nf/nf-storage.js,
js/nf/nf-storage.js.gz,
js/nf/nf-ajax-setup.js,
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/bulletin-board.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/bulletin-board.properties
index 328622f..a64480f 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/bulletin-board.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/bulletin-board.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.bulletin.board.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties
index 5cc9f3f..b509eae 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties
@@ -16,6 +16,7 @@
nf.canvas.script.tags=<script type="text/javascript"
src="js/nf/nf-ng-bridge.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-ng-service-provider.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-cluster-summary.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-ajax-setup.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-universal-capture.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/cluster.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/cluster.properties
index b909227..f4d0fcb 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/cluster.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/cluster.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.cluster.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/counters.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/counters.properties
index 60f923b..dd0f334 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/counters.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/counters.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.counters.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/history.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/history.properties
index 092c1b7..fc744c8 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/history.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/history.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.history.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/login.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/login.properties
index 333bd37..83a69b8 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/login.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/login.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.login.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout.properties
index 70b69e9..bdd9b94 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.logout.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/provenance.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/provenance.properties
index 909e901..0f3e96a 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/provenance.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/provenance.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.provenance.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/summary.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/summary.properties
index 40d180a..a45a07a 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/summary.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/summary.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.summary.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/templates.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/templates.properties
index cb036e0..329130e 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/templates.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/templates.properties
@@ -14,6 +14,7 @@
# limitations under the License.
nf.templates.script.tags=<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/users.properties
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/users.properties
index ed8ff5d..3913788 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/users.properties
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/users.properties
@@ -15,6 +15,7 @@
nf.users.script.tags=<script type="text/javascript"
src="js/nf/nf-client.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-dialog.js?${project.version}"></script>\n\
+<script type="text/javascript"
src="js/nf/nf-authorization-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript"
src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
index 6a8a916..dc5d146 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
@@ -28,6 +28,7 @@
'nf.ng.Bridge',
'nf.ClusterSummary',
'nf.ErrorHandler',
+ 'nf.AuthorizationStorage',
'nf.Storage',
'nf.CanvasUtils',
'nf.Birdseye',
@@ -35,8 +36,8 @@
'nf.Actions',
'nf.ProcessGroup',
'nf.ParameterContexts'],
- function ($, d3, nfCommon, nfDialog, nfGraph, nfShell, nfNgBridge,
nfClusterSummary, nfErrorHandler, nfStorage, nfCanvasUtils, nfBirdseye,
nfContextMenu, nfActions, nfProcessGroup, nfParameterContexts) {
- return (nf.Canvas = factory($, d3, nfCommon, nfDialog,
nfGraph, nfShell, nfNgBridge, nfClusterSummary, nfErrorHandler, nfStorage,
nfCanvasUtils, nfBirdseye, nfContextMenu, nfActions, nfProcessGroup,
nfParameterContexts));
+ function ($, d3, nfCommon, nfDialog, nfGraph, nfShell, nfNgBridge,
nfClusterSummary, nfErrorHandler, nfAuthorizationStorage, nfStorage,
nfCanvasUtils, nfBirdseye, nfContextMenu, nfActions, nfProcessGroup,
nfParameterContexts) {
+ return (nf.Canvas = factory($, d3, nfCommon, nfDialog,
nfGraph, nfShell, nfNgBridge, nfClusterSummary, nfErrorHandler,
nfAuthorizationStorage, nfStorage, nfCanvasUtils, nfBirdseye, nfContextMenu,
nfActions, nfProcessGroup, nfParameterContexts));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Canvas =
@@ -49,6 +50,7 @@
require('nf.ng.Bridge'),
require('nf.ClusterSummary'),
require('nf.ErrorHandler'),
+ require('nf.AuthorizationStorage'),
require('nf.Storage'),
require('nf.CanvasUtils'),
require('nf.Birdseye'),
@@ -66,6 +68,7 @@
root.nf.ng.Bridge,
root.nf.ClusterSummary,
root.nf.ErrorHandler,
+ root.nf.AuthorizationStorage,
root.nf.Storage,
root.nf.CanvasUtils,
root.nf.Birdseye,
@@ -74,7 +77,7 @@
root.nf.ProcessGroup,
root.nf.ParameterContexts);
}
-}(this, function ($, d3, nfCommon, nfDialog, nfGraph, nfShell, nfNgBridge,
nfClusterSummary, nfErrorHandler, nfStorage, nfCanvasUtils, nfBirdseye,
nfContextMenu, nfActions, nfProcessGroup, nfParameterContexts) {
+}(this, function ($, d3, nfCommon, nfDialog, nfGraph, nfShell, nfNgBridge,
nfClusterSummary, nfErrorHandler, nfAuthorizationStorage, nfStorage,
nfCanvasUtils, nfBirdseye, nfContextMenu, nfActions, nfProcessGroup,
nfParameterContexts) {
'use strict';
var SCALE = 1;
@@ -105,6 +108,7 @@
var config = {
urls: {
api: '../nifi-api',
+ accessStatus: '../nifi-api/access',
currentUser: '../nifi-api/flow/current-user',
controllerBulletins: '../nifi-api/flow/controller/bulletins',
kerberos: '../nifi-api/access/kerberos',
@@ -858,15 +862,12 @@
init: function () {
// attempt kerberos/oidc/saml authentication
var ticketExchange = $.Deferred(function (deferred) {
- var successfulAuthentication = function (jwt) {
- // get the payload and store the token with the
appropriate expiration
- var token = nfCommon.getJwtPayload(jwt);
- var expiration = parseInt(token['exp'], 10) *
nfCommon.MILLIS_PER_SECOND;
- nfStorage.setItem('jwt', jwt, expiration);
+ var successfulAuthentication = function (token) {
+ nfAuthorizationStorage.setToken(token)
deferred.resolve();
};
- if (nfStorage.hasItem('jwt')) {
+ if (nfAuthorizationStorage.hasToken()) {
deferred.resolve();
} else {
$.ajax({
@@ -907,8 +908,22 @@
$('#current-user').text(currentUser.identity).show();
// render the logout button if there is a token
locally
- if (nfStorage.getItem('jwt') !== null) {
+ if (nfAuthorizationStorage.hasToken()) {
$('#logout-link-container').show();
+ } else {
+ // Check Access Status when Token not found to
remove Session Cookie if needed
+ $.ajax({
+ type: 'GET',
+ url: config.urls.accessStatus,
+ dataType: 'json'
+ }).done(function (response) {
+ var accessStatus = response.accessStatus;
+ if (accessStatus.status === 'UNKNOWN') {
+ window.location = '../nifi/login';
+ }
+ }).fail(function () {
+ window.location = '../nifi/login';
+ });
}
} else {
// set the anonymous user label
@@ -918,7 +933,7 @@
}).fail(function (xhr, status, error) {
// there is no anonymous access and we don't know this
user - open the login page which handles login/registration/etc
if (xhr.status === 401) {
- nfStorage.removeItem('jwt');
+ nfAuthorizationStorage.removeToken();
window.location = '../nifi/login';
} else {
deferred.reject(xhr, status, error);
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 72cd6c2..22f1a73 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
@@ -22,23 +22,26 @@
define(['jquery',
'nf.Common',
'nf.Dialog',
+ 'nf.AuthorizationStorage',
'nf.Storage'],
- function ($, nfCommon, nfDialog, nfStorage) {
- return (nf.Login = factory($, nfCommon, nfDialog, nfStorage));
+ function ($, nfCommon, nfDialog, nfAuthorizationStorage,
nfStorage) {
+ return (nf.Login = factory($, nfCommon, nfDialog,
nfAuthorizationStorage, nfStorage));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Login =
factory(require('jquery'),
require('nf.Common'),
require('nf.Dialog'),
+ require('nf.AuthorizationStorage'),
require('nf.Storage')));
} else {
nf.Login = factory(root.$,
root.nf.Common,
root.nf.Dialog,
+ root.nf.AuthorizationStorage,
root.nf.Storage);
}
-}(this, function ($, nfCommon, nfDialog, nfStorage) {
+}(this, function ($, nfCommon, nfDialog, nfAuthorizationStorage, nfStorage) {
'use strict';
$(document).ready(function () {
@@ -99,10 +102,7 @@
'password': $('#password').val()
}
}).done(function (jwt) {
- // Get the payload and store the token with the appropriate
expiration. JWT is also stored automatically in a cookie.
- var token = nfCommon.getJwtPayload(jwt);
- var expiration = parseInt(token['exp'], 10) *
nfCommon.MILLIS_PER_SECOND;
- nfStorage.setItem('jwt', jwt, expiration);
+ nfAuthorizationStorage.setToken(jwt);
// check to see if they actually have access now
$.ajax({
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js
index ac5bc1c..ab022ba 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js
@@ -20,18 +20,18 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
- 'nf.Storage'],
- function ($, nfStorage) {
- return (nf.AjaxSetup = factory($, nfStorage));
+ 'nf.AuthorizationStorage'],
+ function ($, nfAuthorizationStorage) {
+ return (nf.AjaxSetup = factory($, nfAuthorizationStorage));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.AjaxSetup = factory(require('jquery'),
- require('nf.Storage')));
+ require('nf.AuthorizationStorage')));
} else {
nf.AjaxSetup = factory(root.$,
- root.nf.Storage);
+ root.nf.AuthorizationStorage);
}
-}(this, function ($, nfStorage) {
+}(this, function ($, nfAuthorizationStorage) {
/**
* Performs ajax setup for use within NiFi.
*/
@@ -39,10 +39,10 @@
// include jwt when possible
$.ajaxSetup({
'beforeSend': function (xhr) {
- var hadToken = nfStorage.hasItem('jwt');
+ var hadToken = nfAuthorizationStorage.hasToken();
// get the token to include in all requests
- var token = nfStorage.getItem('jwt');
+ var token = nfAuthorizationStorage.getToken();
if (token !== null) {
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
} else {
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-authorization-storage.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-authorization-storage.js
new file mode 100644
index 0000000..2b78c89
--- /dev/null
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-authorization-storage.js
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* global define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define([], function () {
+ return (nf.AuthorizationStorage = factory());
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.AuthorizationStorage = factory());
+ } else {
+ nf.AuthorizationStorage = factory();
+ }
+}(this, function () {
+ var TOKEN_ITEM_KEY = 'nifi-authorization-token';
+
+ return {
+ /**
+ * Get Token from Session Storage
+ *
+ * @return Bearer Token string
+ */
+ getToken: function () {
+ return sessionStorage.getItem(TOKEN_ITEM_KEY);
+ },
+
+ /**
+ * Has Token returns the status of whether Session Storage contains
the Token
+ *
+ * @return Boolean status of whether Session Storage contains the Token
+ */
+ hasToken: function () {
+ var token = this.getToken();
+ return typeof token === 'string';
+ },
+
+ /**
+ * Remove Token from Session Storage
+ *
+ */
+ removeToken: function () {
+ sessionStorage.removeItem(TOKEN_ITEM_KEY);
+ },
+
+ /**
+ * Set Token in Session Storage
+ *
+ * @param token Token String
+ */
+ setToken: function (token) {
+ sessionStorage.setItem(TOKEN_ITEM_KEY, token);
+ }
+ };
+}));
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
index 3d46d8b..41a36e9 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js
@@ -22,26 +22,26 @@
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
- 'nf.Storage',
+ 'nf.AuthorizationStorage',
'lodash-core',
'moment'],
- function ($, d3, nfStorage, _, moment) {
- return (nf.Common = factory($, d3, nfStorage, _, moment));
+ function ($, d3, nfAuthorizationStorage, _, moment) {
+ return (nf.Common = factory($, d3, nfAuthorizationStorage, _,
moment));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Common = factory(require('jquery'),
require('d3'),
- require('nf.Storage'),
+ require('nf.AuthorizationStorage'),
require('lodash-core'),
require('moment')));
} else {
nf.Common = factory(root.$,
root.d3,
- root.nf.Storage,
+ root.nf.AuthorizationStorage,
root._,
root.moment);
}
-}(this, function ($, d3, nfStorage, _, moment) {
+}(this, function ($, d3, nfAuthorizationStorage, _, moment) {
'use strict';
$(document).ready(function () {
@@ -91,7 +91,7 @@
});
// shows the logout link in the message-pane when appropriate and
schedule token refresh
- if (nfStorage.getItem('jwt') !== null) {
+ if (nfAuthorizationStorage.hasToken()) {
$('#user-logout-container').css('display', 'block');
nfCommon.scheduleTokenRefresh();
}
@@ -102,7 +102,7 @@
type: 'DELETE',
url: '../nifi-api/access/logout',
}).done(function () {
- nfStorage.removeItem("jwt");
+ nfAuthorizationStorage.removeToken();
window.location = '../nifi/logout';
}).fail(nfErrorHandler.handleAjaxError);
});
@@ -505,10 +505,13 @@
var interval = nfCommon.MILLIS_PER_MINUTE;
var checkExpiration = function () {
- var expiration = nfStorage.getItemExpiration('jwt');
+ var token = nfAuthorizationStorage.getToken();
// ensure there is an expiration and token present
- if (expiration !== null) {
+ if (token !== null) {
+ var jsonWebToken = nfCommon.getJwtPayload(token);
+ var expiration = parseInt(jsonWebToken['exp'], 10) *
nfCommon.MILLIS_PER_SECOND;
+
var expirationDate = new Date(expiration);
var now = new Date();
@@ -853,7 +856,7 @@
* Shows the logout link if appropriate.
*/
updateLogoutLink: function () {
- if (nfStorage.getItem('jwt') !== null) {
+ if (nfAuthorizationStorage.hasToken()) {
$('#user-logout-container').css('display', 'block');
} else {
$('#user-logout-container').css('display', 'none');
diff --git
a/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/WEB-INF/jsp/index.jsp
b/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/WEB-INF/jsp/index.jsp
index d97f77b..7271320 100644
---
a/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/WEB-INF/jsp/index.jsp
+++
b/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/WEB-INF/jsp/index.jsp
@@ -35,6 +35,7 @@
<script type="text/javascript"
src="../nifi/js/codemirror/addon/lint/lint.js"></script>
<script type="text/javascript"
src="../nifi/js/codemirror/addon/lint/json-lint.js"></script>
<script type="text/javascript" src="../nifi/js/nf/nf-namespace.js"></script>
+<script type="text/javascript"
src="../nifi/js/nf/nf-authorization-storage.js"></script>
<script type="text/javascript" src="../nifi/js/nf/nf-storage.js"></script>
<script type="text/javascript"
src="../nifi/assets/angular/angular.min.js"></script>
<script type="text/javascript"
src="../nifi/assets/angular-animate/angular-animate.min.js"></script>
diff --git
a/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/app/app.js
b/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/app/app.js
index 8c6827b..c011367 100644
---
a/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/app/app.js
+++
b/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/src/main/webapp/app/app.js
@@ -19,8 +19,8 @@
var AppRun = function($rootScope,$state,$http){
- if (nf.Storage.hasItem('jwt')) {
- var token = nf.Storage.getItem('jwt');
+ if (nf.AuthorizationStorage.hasToken()) {
+ var token = nf.AuthorizationStorage.getToken();
$http.defaults.headers.common.Authorization = 'Bearer ' + token;
}
diff --git
a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/webapp/WEB-INF/jsp/worksheet.jsp
b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/webapp/WEB-INF/jsp/worksheet.jsp
index 1a1f80a..475ff6d 100644
---
a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/webapp/WEB-INF/jsp/worksheet.jsp
+++
b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/webapp/WEB-INF/jsp/worksheet.jsp
@@ -56,6 +56,7 @@
<script type="text/javascript"
src="../nifi/assets/slickgrid/slick.grid.js"></script>
<script type="text/javascript"
src="../nifi/js/codemirror/lib/codemirror-compressed.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-namespace.js"></script>
+ <script type="text/javascript"
src="../nifi/js/nf/nf-authorization-storage.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-storage.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-ajax-setup.js"></script>
<script type="text/javascript"
src="../nifi/js/nf/nf-universal-capture.js"></script>