You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2020/10/07 16:17:13 UTC
[nifi] branch main updated: NIFI-7892 Created a Logout page to
inform users of a complete logout when OIDC is configured. (#4579)
This is an automated email from the ASF dual-hosted git repository.
bbende 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 de39a3d NIFI-7892 Created a Logout page to inform users of a complete logout when OIDC is configured. (#4579)
de39a3d is described below
commit de39a3d9f4c8a01f193b0258173cee5694c87f0d
Author: M Tien <56...@users.noreply.github.com>
AuthorDate: Wed Oct 7 09:17:00 2020 -0700
NIFI-7892 Created a Logout page to inform users of a complete logout when OIDC is configured. (#4579)
---
.../org/apache/nifi/web/api/AccessResource.java | 4 +-
.../nifi-framework/nifi-web/nifi-web-ui/pom.xml | 35 +++++++++++++-
.../org/apache/nifi/web/filter/LogoutFilter.java | 4 +-
.../main/resources/filters/logout-min.properties | 19 ++++++++
.../src/main/resources/filters/logout.properties | 28 +++++++++++
.../src/main/webapp/WEB-INF/pages/logout.jsp | 54 +++++++++++++++++++++
.../WEB-INF/partials/logout/logout-message.jsp | 21 +++++++++
.../nifi-web-ui/src/main/webapp/WEB-INF/web.xml | 10 ++++
.../nifi-web-ui/src/main/webapp/css/logout.css | 55 ++++++++++++++++++++++
.../src/main/webapp/js/nf/logout/nf-logout.js | 44 +++++++++++++++++
10 files changed, 269 insertions(+), 5 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 5ee98cd..9a3eec2 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
@@ -337,7 +337,7 @@ public class AccessResource extends ApplicationResource {
}
URI endSessionEndpoint = oidcService.getEndSessionEndpoint();
- String postLogoutRedirectUri = generateResourceUri("..", "nifi");
+ String postLogoutRedirectUri = generateResourceUri("..", "nifi", "logout-complete");
if (endSessionEndpoint == null) {
// handle the case, where the OpenID Provider does not have an end session endpoint
@@ -777,7 +777,7 @@ public class AccessResource extends ApplicationResource {
try {
logger.info("Logging out user " + userIdentity);
jwtService.logOutUsingAuthHeader(httpServletRequest.getHeader(JwtAuthenticationFilter.AUTHORIZATION));
- logger.info("Successfully logged out user" + userIdentity);
+ logger.info("Successfully logged out user " + userIdentity);
return generateOkResponse().build();
} catch (final JwtException e) {
logger.error("Logout of user " + userIdentity + " failed due to: " + e.getMessage());
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 4fa26e7..629490f 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
@@ -36,6 +36,7 @@
<users.filter>users.properties</users.filter>
<bulletin.board.filter>bulletin-board.properties</bulletin.board.filter>
<login.filter>login.properties</login.filter>
+ <logout.filter>logout.properties</logout.filter>
<provenance.filter>provenance.properties</provenance.filter>
<frontend.dependency.configs>${basedir}/src/main/frontend</frontend.dependency.configs>
<frontend.working.dir>${project.build.directory}/frontend-working-directory</frontend.working.dir>
@@ -66,6 +67,7 @@
<filter>src/main/resources/filters/${users.filter}</filter>
<filter>src/main/resources/filters/${bulletin.board.filter}</filter>
<filter>src/main/resources/filters/${login.filter}</filter>
+ <filter>src/main/resources/filters/${logout.filter}</filter>
<filter>src/main/resources/filters/${provenance.filter}</filter>
</filters>
<plugins>
@@ -101,7 +103,8 @@
**/templates.jsp,
**/users.jsp,
**/bulletin-board.jsp,
- **/login.jsp
+ **/login.jsp,
+ **/logout.jsp
</excludes>
</configuration>
</execution>
@@ -362,6 +365,14 @@
</includes>
<filtering>true</filtering>
</resource>
+ <resource>
+ <directory>src/main/webapp/WEB-INF/pages</directory>
+ <targetPath>WEB-INF/pages</targetPath>
+ <includes>
+ <include>logout.jsp</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
</webResources>
</configuration>
</plugin>
@@ -447,6 +458,7 @@
<users.filter>users-min.properties</users.filter>
<bulletin.board.filter>bulletin-board-min.properties</bulletin.board.filter>
<login.filter>login-min.properties</login.filter>
+ <logout.filter>logout-min.properties</logout.filter>
<provenance.filter>provenance-min.properties</provenance.filter>
</properties>
<build>
@@ -706,6 +718,13 @@
</aggregation>
<aggregation>
<insertNewLine>true</insertNewLine>
+ <output>${project.build.directory}/${project.build.finalName}/js/nf/logout/nf-logout-all.js</output>
+ <includes>
+ <include>${staging.dir}/js/nf/logout/nf-logout.js</include>
+ </includes>
+ </aggregation>
+ <aggregation>
+ <insertNewLine>true</insertNewLine>
<output>${project.build.directory}/${project.build.finalName}/css/nf-canvas-all.css</output>
<includes>
<include>${staging.dir}/css/reporting-task.css</include>
@@ -841,6 +860,16 @@
<include>${staging.dir}/css/login.css</include>
</includes>
</aggregation>
+ <aggregation>
+ <insertNewLine>true</insertNewLine>
+ <output>${project.build.directory}/${project.build.finalName}/css/nf-logout-all.css</output>
+ <includes>
+ <include>${staging.dir}/css/main.css</include>
+ <include>${staging.dir}/css/banner.css</include>
+ <include>${staging.dir}/css/dialog.css</include>
+ <include>${staging.dir}/css/logout.css</include>
+ </includes>
+ </aggregation>
</aggregations>
</configuration>
</execution>
@@ -887,6 +916,8 @@
css/nf-bulletin-board-all.css.gz,
css/nf-login-all.css,
css/nf-login-all.css.gz,
+ css/nf-logout-all.css,
+ css/nf-logout-all.css.gz,
js/*,
js/d3/**/*,
js/codemirror/**/*,
@@ -927,6 +958,8 @@
js/nf/bulletin-board/nf-bulletin-board-all.js.gz,
js/nf/login/nf-login-all.js,
js/nf/login/nf-login-all.js.gz,
+ js/nf/logout/nf-logout-all.js,
+ js/nf/logout/nf-logout-all.js.gz,
views/*,
fonts/**/*,
images/*,
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/filter/LogoutFilter.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/filter/LogoutFilter.java
index 08f9365..89e1821 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/filter/LogoutFilter.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/java/org/apache/nifi/web/filter/LogoutFilter.java
@@ -16,6 +16,7 @@
*/
package org.apache.nifi.web.filter;
+import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -24,7 +25,6 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
/**
* Filter for determining appropriate logout location.
@@ -50,7 +50,7 @@ public class LogoutFilter implements Filter {
final ServletContext apiContext = servletContext.getContext("/nifi-api");
apiContext.getRequestDispatcher("/access/knox/logout").forward(request, response);
} else {
- ((HttpServletResponse) response).sendRedirect("login");
+ ((HttpServletResponse) response).sendRedirect("logout-complete");
}
}
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout-min.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout-min.properties
new file mode 100644
index 0000000..4e385da
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout-min.properties
@@ -0,0 +1,19 @@
+# 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.
+
+nf.logout.script.tags=<script type="text/javascript" src="js/nf/logout/nf-logout-all.js?${project.version}"></script>
+nf.logout.style.tags=<link rel="stylesheet" href="css/nf-logout-all.css?${project.version}" type="text/css" />\n\
+<link rel="stylesheet" href="css/message-pane.css?${project.version}" type="text/css" />\n\
+<link rel="stylesheet" href="css/nf-common-ui.css?${project.version}" type="text/css" />
\ No newline at end of file
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
new file mode 100644
index 0000000..70b69e9
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/logout.properties
@@ -0,0 +1,28 @@
+# 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.
+
+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-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\
+<script type="text/javascript" src="js/nf/nf-universal-capture.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/logout/nf-logout.js?${project.version}"></script>
+nf.logout.style.tags=<link rel="stylesheet" href="css/main.css?${project.version}" type="text/css" />\n\
+<link rel="stylesheet" href="css/common-ui.css?${project.version}" type="text/css" />\n\
+<link rel="stylesheet" href="css/banner.css?${project.version}" type="text/css" />\n\
+<link rel="stylesheet" href="css/dialog.css?${project.version}" type="text/css" />\n\
+<link rel="stylesheet" href="css/message-pane.css?${project.version}" type="text/css" />\n\
+<link rel="stylesheet" href="css/logout.css?${project.version}" type="text/css" />
\ 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/WEB-INF/pages/logout.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/logout.jsp
new file mode 100644
index 0000000..07a8a40
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/logout.jsp
@@ -0,0 +1,54 @@
+<%--
+ 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.
+--%>
+<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>NiFi Logout</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="shortcut icon" href="images/nifi16.ico"/>
+ <link rel="stylesheet" href="assets/reset.css/reset.css" type="text/css" />
+ <link rel="stylesheet" href="fonts/flowfont/flowfont.css" type="text/css" />
+ ${nf.logout.style.tags}
+ <link rel="stylesheet" href="js/jquery/modal/jquery.modal.css?${project.version}" type="text/css" />
+ <link rel="stylesheet" href="assets/qtip2/dist/jquery.qtip.min.css?" type="text/css" />
+ <link rel="stylesheet" href="assets/jquery-ui-dist/jquery-ui.min.css" type="text/css" />
+ <link rel="stylesheet" href="fonts/flowfont/flowfont.css" type="text/css" />
+ <script type="text/javascript" src="assets/jquery/dist/jquery.min.js"></script>
+ <script type="text/javascript" src="js/jquery/jquery.base64.js"></script>
+ <script type="text/javascript" src="js/jquery/jquery.count.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="assets/qtip2/dist/jquery.qtip.min.js"></script>
+ <script type="text/javascript" src="assets/jquery-ui-dist/jquery-ui.min.js"></script>
+ <script type="text/javascript" src="js/nf/nf-namespace.js?${project.version}"></script>
+ <script type="text/javascript" src="assets/lodash-core/distrib/lodash-core.min.js"></script>
+ ${nf.logout.script.tags}
+ </head>
+ <body class="logout-body">
+ <div id="logout-user-links-container">
+ <ul id="logout-user-links" class="links">
+ <li>
+ <span id="user-home" class="link">home</span>
+ </li>
+ </ul>
+ </div>
+ <div id="logout-contents-container">
+ <jsp:include page="/WEB-INF/partials/logout/logout-message.jsp"/>
+ </div>
+ </body>
+</html>
\ 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/WEB-INF/partials/logout/logout-message.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/logout/logout-message.jsp
new file mode 100644
index 0000000..32e700a
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/logout/logout-message.jsp
@@ -0,0 +1,21 @@
+<%--
+ 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.
+--%>
+<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
+<div id="logout-message-container">
+ <div id="logout-message-title"><p>Logout successful</p></div>
+ <div id="logout-message"><p>You have have successfully logged out. You may now close the window.</p></div>
+</div>
\ 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/WEB-INF/web.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/web.xml
index 6b8f97e..52502fc 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/web.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/web.xml
@@ -126,6 +126,16 @@
<url-pattern>/login</url-pattern>
</servlet-mapping>
+ <!-- servlet to logout page -->
+ <servlet>
+ <servlet-name>Logout</servlet-name>
+ <jsp-file>/WEB-INF/pages/logout.jsp</jsp-file>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Logout</servlet-name>
+ <url-pattern>/logout-complete</url-pattern>
+ </servlet-mapping>
+
<!-- login filter -->
<filter>
<filter-name>LoginFilter</filter-name>
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/logout.css b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/logout.css
new file mode 100644
index 0000000..074424e
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/logout.css
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+/*
+ Logout Styles
+*/
+
+#logout-contents-container {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ bottom: 0px;
+ right: 0px;
+ background: #fff url(../images/bg-error.png) left top no-repeat;
+ padding-top: 100px;
+ padding-left: 100px;
+}
+
+#logout-message-title {
+ font-size: 18px;
+ color: #294c58;
+ margin-bottom: 16px;
+}
+
+#logout-message {
+ font-size: 11px;
+}
+
+#logout-user-links-container {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ padding-top: 100px;
+ padding-left: 100px;
+ z-index: 1300;
+ width: 412px;
+}
+
+#logout-user-links {
+ float: right;
+}
\ 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/logout/nf-logout.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/logout/nf-logout.js
new file mode 100644
index 0000000..0259a23
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/logout/nf-logout.js
@@ -0,0 +1,44 @@
+/*
+ * 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 top, define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery'],
+ function ($) {
+ return (nf.Logout = factory($));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.Logout =
+ factory(require('jquery')));
+ } else {
+ nf.Logout = factory(root.$);
+ }
+}(this, function ($) {
+ 'use strict';
+
+ $(document).ready(function () {
+ $('#user-home').on('mouseenter', function () {
+ $(this).addClass('link-over');
+ }).on('mouseleave', function () {
+ $(this).removeClass('link-over');
+ }).on('click', function () {
+ window.location = '../nifi';
+ });
+ });
+}));
\ No newline at end of file