Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added options to provide basic authentication in Hop Web container + … #2446

Merged
merged 1 commit into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docker/resources/run-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ else
fi


# if we have a /config/tomcat-users.xml file, copy it to the conf folder.
if [ -f "/config/tomcat-users.xml" ]; then
log "copying users file to /usr/local/tomcat/conf/"
cp /config/tomcat-users.xml /usr/local/tomcat/conf/
fi

# if we have a /config/web.xml file, copy it to the WEB-INF folder.
if [ -f "/config/web.xml" ]; then
log "copying web.xml file to /usr/local/tomcat/conf/"
cp /config/web.xml /usr/local/tomcat/webapps/ROOT/WEB-INF/
fi

#
# Stopping a running hop web container with 'docker stop' is obviously possible.
# Doing it with CTRL-C is just more convenient.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 140 additions & 0 deletions docs/hop-user-manual/modules/ROOT/pages/hop-gui/hop-web.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,143 @@ docker run -it --rm \
Hop Web contains the default xref:hop-tools/index.adoc[Hop tools] like xref:hop-tools/hop-conf/hop-conf.adoc[hop-conf], xref:hop-run/index.adoc[hop-run] etc.

The tools are available in `/usr/local/tomcat/webapps/ROOT` in a running Hop Web container.

== Authentication

Hop Web runs on a Tomcat server by default. You can extend Hop Web's tomcat configuration to add authentication.

The default Hop Web docker image picks up `tomcat-users.xml` and `web.xml` files and moves them to the correct location before Hop Web starts.

A minimal sample `tomcat-users.xml` file:

[source,xml]
----
<?xml version='1.0' encoding='utf-8'?>
<!--
~ 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.
~
-->
<tomcat-users>
<role rolename="apachehop"/>
<user username="apachehop" password="password" roles="apachehop" />
</tomcat-users>
----

The following sample `web.xml` extends Hop Web's default `web.xml` with the `<security-constraint />` and `<login-config />` elements required for basic authentication.

[source, xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<context-param>
<param-name>org.eclipse.rap.applicationConfiguration</param-name>
<param-value>org.apache.hop.ui.hopgui.HopWeb</param-value>
</context-param>

<listener>
<listener-class>org.apache.hop.ui.hopgui.HopWebServletContextListener</listener-class>
</listener>

<servlet>
<servlet-name>HopGui</servlet-name>
<servlet-class>org.eclipse.rap.rwt.engine.RWTServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HopGui</servlet-name>
<url-pattern>/ui</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>welcome</servlet-name>
<jsp-file>/docs/English/welcome/index.html</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>welcome</servlet-name>
<url-pattern>/docs/English/welcome/index.html</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>Server</servlet-name>
<servlet-class>org.apache.hop.www.HopServerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Server</servlet-name>
<url-pattern>/hop/*</url-pattern>
</servlet-mapping>

<security-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>apachehop</role-name>
</auth-constraint>

<user-data-constraint>
<!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE -->
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
</login-config>

</web-app>
----

Check the https://tomcat.apache.org/tomcat-9.0-doc/realm-howto.html[Apache Tomcat documentation^] on REALM configuration for more advanced configurations.

Mount your local configuration folder with these two files to a `/config` folder in the Apache Hop Web container to do so:

[source,bash]
----
docker run -it --rm \
-p 8080:8080 \
-v <PATH_TO_YOUR_LOCAL_CONFIG_DIRECTORY>:/config/ \
apache/hop-web`
----

Hop Web will now ask for your username and password:

image:hop-gui/hop-web-basic-authentication.png[Hop Web with basic authentication, width="90%"]