Skip to content

Commit 2a8bd1d

Browse files
authored
[#3398] Add section about Jetty/JAAS (#64)
1 parent 70a4b68 commit 2a8bd1d

File tree

1 file changed

+67
-22
lines changed

1 file changed

+67
-22
lines changed

modules/ROOT/pages/security.adoc

+67-22
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Hawtio can be secured with the authentication mechanisms Quarkus provides, as we
6262

6363
if you want to disable Hawtio authentication for Quarkus, add the following configuration to `application.properties`:
6464

65-
[source,java]
65+
[source,properties]
6666
.application.properties
6767
----
6868
quarkus.hawtio.authenticationEnabled = false
@@ -89,7 +89,7 @@ To use the properties-based authentication with Hawtio, add the following depend
8989

9090
You can then define users to `application.properties` to enable the authentication. For example, defining a user `hawtio` with password `s3cr3t!` and role `admin` would look like the following:
9191

92-
[source,java]
92+
[source,properties]
9393
.application.properties
9494
----
9595
quarkus.security.users.embedded.enabled = true
@@ -112,7 +112,7 @@ In addition to the standard JAAS authentication, Hawtio on Spring Boot can be se
112112

113113
if you want to disable Hawtio authentication for Spring Boot, add the following configuration to `application.properties`:
114114

115-
[source,java]
115+
[source,properties]
116116
.application.properties
117117
----
118118
hawtio.authenticationEnabled = false
@@ -132,7 +132,7 @@ To use Spring Security with Hawtio, add `org.springframework.boot:spring-boot-st
132132

133133
Spring Security configuration in `src/main/resources/application.properties` should look something like the following:
134134

135-
[source,java]
135+
[source,properties]
136136
----
137137
spring.security.user.name = hawtio
138138
spring.security.user.password = s3cr3t!
@@ -216,45 +216,73 @@ See xref:keycloak.adoc#_spring_boot[Keycloak Integration - Spring Boot].
216216

217217
Hawtio authentication is enabled by default. If you want to disable Hawtio authentication, set the following system property:
218218

219-
[source,java]
219+
[source,properties]
220220
----
221221
hawtio.authenticationEnabled = false
222222
----
223223

224224
=== Jetty
225225

226-
To use authentication with Jetty, you first have to set up some users with roles. To do that navigate to the `etc/` folder of your Jetty installation and create the following file `etc/login.properties` and enter something like this:
226+
Hawtio can integrate with Jetty JAAS mechanisms. However not all https://jetty.org/docs/jetty/12/operations-guide/jaas/index.html#loginmodules[Jetty JAAS modules] work out of the box.
227227

228-
[source,java]
228+
Jetty JAAS modules work with Jetty security infrastructure and the important thing is that it requires your web application (WAR) to use `<login-config>` configuration.
229+
230+
Hawtio provides customized `org.eclipse.jetty.security.jaas.spi.PropertyFileLoginModule` which is available in `io.hawt.jetty.security.jaas.PropertyFileLoginModule` class. Additionally Hawtio provides ready to use `*.mod` file which can be copied directly to `$JETTY_BASE/modules`. This file describes https://jetty.org/docs/jetty/12/operations-guide/modules/index.html[Jetty module] with references to required Hawtio Jetty library:
231+
232+
[source]
233+
----
234+
[description]
235+
Hawtio JAAS Login Module Configuration for Jetty
236+
237+
[tags]
238+
security
239+
hawtio
240+
241+
[depends]
242+
jaas
243+
244+
[files]
245+
maven://io.hawt/hawtio-jetty-security/<version>|lib/hawtio-jetty-security-<version>.jar
246+
247+
[lib]
248+
lib/hawtio-jetty-security-<version>.jar
249+
----
250+
251+
After adding `$JETTY_BASE/modules/hawtio-jetty-security.mod` file we can add this module (and `jaas` module) using:
252+
253+
[source,shell]
254+
----
255+
$ cd $JETTY_BASE
256+
$ java -jar $JETTY_HOME/start.jar --add-module=jaas,hawtio-jetty-security
257+
INFO : jaas initialized in ${jetty.base}/start.d/jaas.ini
258+
INFO : hawtio-jetty-security initialized in ${jetty.base}/start.d/hawtio-jetty-security.ini
259+
INFO : copy ~/.m2/repository/io/hawt/hawtio-jetty-security/4.4-SNAPSHOT/hawtio-jetty-security-<version>.jar to ${jetty.base}/lib/hawtio-jetty-security-<version>.jar
260+
INFO : Base directory was modified
261+
----
262+
263+
To use authentication with Jetty, you first have to set up some users with credentials and roles. To do that navigate to `$JETTY_BASE/etc/` folder and create `etc/login.properties` file containing something like this:
264+
265+
[source,properties]
229266
.etc/login.properties
230267
----
231-
scott=tiger, user
268+
scott=tiger,user
232269
admin=CRYPT:adpexzg3FUZAk,admin,user
233270
----
234271

235-
You have added two users. The first one named `scott` with the password `tiger`. He has the role `user` assigned to it. The second user `admin` with password `admin` which is obfuscated (see Jetty realms for possible encryption methods). This one has the `admin` and `user` role assigned.
272+
You have added two users. The first one named `scott` with the password `tiger`. He has the role `user` assigned to it. The second user `admin` with password `admin` which is obfuscated (see https://jetty.org/docs/jetty/12/operations-guide/tools/index.html#password[Password Obfuscation in Jetty documentation] for details). This one has the `admin` and `user` role assigned.
236273

237-
Now create the second file in the same `etc/` directory called `login.conf`. This is the login configuration file.
274+
Now create the second file in the same `$JETTY_BASE/etc/` directory named `login.conf`. This is the JAAS login configuration file.
238275

239-
[source,java]
276+
[source]
240277
.etc/login.conf
241278
----
242279
hawtio {
243-
org.eclipse.jetty.jaas.spi.PropertyFileLoginModule required
280+
io.hawt.jetty.security.jaas.PropertyFileLoginModule required
244281
debug="true"
245282
file="${jetty.base}/etc/login.properties";
246283
};
247284
----
248285

249-
CAUTION: Currently the login module `org.eclipse.jetty.jaas.spi.PropertyFileLoginModule` doesn't work with Hawtio. The instructions are kept as-is for illustrative purposes. But to really make it work, use https://eclipse.dev/jetty/documentation/jetty-10/operations-guide/index.html#og-jaas-loginmodules[different login modules] or implement your own `PropertyFileLoginModule`.
250-
251-
Next, enable the JAAS module in Jetty. This is done by the following command:
252-
253-
[source,console]
254-
----
255-
$ java -jar $JETTY_HOME/start.jar --add-module=jaas
256-
----
257-
258286
At last, you have to change the Hawtio configuration:
259287

260288
[cols="5,5"]
@@ -272,9 +300,22 @@ At last, you have to change the Hawtio configuration:
272300
|`admin`
273301

274302
|`hawtio.rolePrincipalClasses`
275-
|`org.eclipse.jetty.jaas.JAASRole`
303+
|`org.eclipse.jetty.security.jaas.JAASRole`
276304
|===
277305

306+
When Jetty `jvm` module is installed, we can specify Hawtio properties in `$JETTY_BASE/start.d/jvm.ini`:
307+
308+
[source,ini]
309+
----
310+
--exec
311+
-Dhawtio.authenticationEnabled=true
312+
-Dhawtio.realm=hawtio
313+
-Dhawtio.roles=admin
314+
-Dhawtio.rolePrincipalClasses=org.eclipse.jetty.security.jaas.JAASRole
315+
----
316+
317+
Without `jvm` module the above options should be specified as system properties when running `java -jar $JETTY_HOME/start.jar`.
318+
278319
You have now enabled authentication for Hawtio. Only users with role `admin` are allowed for login.
279320

280321
=== Apache Tomcat
@@ -327,3 +368,7 @@ Then you can configure JAAS in file `TOMCAT_HOME/conf/login.conf` (see <<Jetty>>
327368
== Keycloak Integration
328369

329370
Hawtio can be integrated with https://www.keycloak.org[Keycloak] for SSO authentication. See xref:keycloak.adoc[].
371+
372+
== OpenID Connect Integration
373+
374+
For generic OIDC authentication see xref:oidc.adoc[].

0 commit comments

Comments
 (0)