Skip to content

Commit 6373711

Browse files
committed
docs(HAWNG-1400): Update Keycloak and OpenID Connect documentation
1 parent 5623b90 commit 6373711

File tree

6 files changed

+71
-20
lines changed

6 files changed

+71
-20
lines changed

modules/ROOT/pages/developers/architecture.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
This page presents general information about the Hawtio architecture. We show all the components (client, server, agent connections). For details about plugin development, see xref::developers/applications.adoc[].
44

5+
[#_hawtio_react_single_page_application]
56
== Hawtio React Single Page Application
67
78
Repository: https://github.com/hawtio/hawtio-next

modules/ROOT/pages/get-started.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ $ hawtio --connection=conn1 --connection=conn2 --connection=conn3
9696

9797
In this case, multiple tabs open simultaneously on the browser, each showing the Hawtio console connected to a different connection.
9898

99+
[#_running_a_quarkus_app]
99100
== Running a Quarkus app
100101

101102
You can attach the Hawtio console to your Quarkus application in a single step.
@@ -139,7 +140,7 @@ See the following for a working Quarkus application example.
139140

140141
https://github.com/hawtio/hawtio/tree/hawtio-3.0.0-RC1/examples/quarkus[Quarkus example,window=_blank]
141142

142-
143+
[#_running_a_spring_boot_app]
143144
== Running a Spring Boot app
144145

145146
You can attach the Hawtio console to your Spring Boot application in two steps.
@@ -247,7 +248,7 @@ It is possible to https://jetty.org/docs/jetty/12/operations-guide/deploy/index.
247248
</Configure>
248249
----
249250

250-
But there's a trick here. Normally Jetty unpacks this WAR archive to a temporary folder (which may be specified with `-Djava.io.tmpdir` system property). But there's no need for unpacking if there's `hawtio-war-4.2.0` _directory_ next to `hawtio-war-4.2.0.war` achive.
251+
But there's a trick here. Normally Jetty unpacks this WAR archive to a temporary folder (which may be specified with `-Djava.io.tmpdir` system property). But there's no need for unpacking if there's `hawtio-war-4.2.0` _directory_ next to `hawtio-war-4.2.0.war` archive.
251252

252253
Jetty uses `org.eclipse.jetty.server.SymlinkAllowedResourceAliasChecker` _alias checker_ and if
253254
_real path_ for the above `/data/tmp/hawtio-war-4.2.0` is different (i.e., the path uses symbolic links), resources from this WAR application won't be loaded and Hawtio application won't work.

modules/ROOT/pages/keycloak.adoc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
= Keycloak Integration
22

3+
This chapter presents the legacy method of integration between Hawtio and https://www.keycloak.org[Keycloak]. This method relies on the
4+
availability of Keycloak libraries and Keycloak-specific configuration files, as well as client side https://www.npmjs.com/package/keycloak-js[keycloak.js] library.
5+
6+
For generic OpenID Connect integration (which also supports Keycloak server), please refer to xref:oidc.adoc[] chapter.
7+
38
You can secure your Hawtio console with https://www.keycloak.org[Keycloak]. To integration Hawtio with Keycloak, you need to:
49

510
1. Prepare Keycloak server
@@ -41,6 +46,10 @@ The following settings need to be made for each part:
4146
Server side:: The runtime-specific configuration for the Keycloak adapter
4247
Client side:: The Hawtio Keycloak configuration `keycloak-hawtio.json`
4348

49+
WARNING: Starting with Keycloak 25.0.0, Keycloak specific login modules https://github.com/keycloak/keycloak/issues/28789[are no longer available].
50+
Keycloak can be used with Hawtio using xref:oidc.adoc[]. We can also use Quarkus or SpringBoot specific support for OAuth2 / OpenID Connect which
51+
doesn't rely on Keycloak libraries.
52+
4453
[#_quarkus]
4554
=== Quarkus
4655

@@ -87,7 +96,8 @@ Finally create `keycloak-hawtio.json` under `src/main/resources` in the Quarkus
8796
"clientId": "hawtio-client",
8897
"url": "http://localhost:18080/",
8998
"jaas": false,
90-
"pkceMethod": "S256"
99+
"pkceMethod": "S256",
100+
"logoutUri": "/hawtio/auth/logout"
91101
}
92102
----
93103

@@ -148,7 +158,8 @@ Finally create `keycloak-hawtio.json` under `src/main/resources` in the Spring B
148158
"realm": "hawtio-demo",
149159
"clientId": "hawtio-client",
150160
"url": "http://localhost:18080/",
151-
"jaas": false
161+
"jaas": false,
162+
"logoutUri": "/actuator/hawtio/auth/logout"
152163
}
153164
----
154165

@@ -158,9 +169,10 @@ Build and run the project and it will be integrated with Keycloak.
158169

159170
See https://github.com/hawtio/hawtio/tree/4.x/examples/springboot-keycloak[springboot-keycloak example] for a working example.
160171

172+
////
161173
=== Jetty
162174
163-
CAUTION: Keycloak adapters are https://www.keycloak.org/2022/02/adapter-deprecation[deprecated]. The instructions in this section are not verified with Hawtio v3. It will be updated.
175+
CAUTION: Keycloak adapters are https://www.keycloak.org/2022/02/adapter-deprecation[deprecated]. The instructions in this section are not verified with Hawtio v4. It will be updated.
164176
165177
Assume `$JETTY_HOME` is the root directory of your Jetty installation and you deployed Hawtio WAR to Jetty as described in xref:get-started.adoc[].
166178
@@ -206,7 +218,9 @@ export JAVA_OPTIONS="-Dhawtio.authenticationEnabled=true \
206218
----
207219
208220
Run Jetty and go to `http://localhost:8080/hawtio`. Users are again `admin` and `viewer` with access and `jdoe` without access.
221+
////
209222

223+
////
210224
=== Tomcat
211225
212226
CAUTION: Keycloak adapters are https://www.keycloak.org/2022/02/adapter-deprecation[deprecated]. The instructions in this section are not verified with Hawtio v3. It will be updated.
@@ -219,6 +233,7 @@ Instructions are quite similar to <<Jetty>>. You would need to setup JAAS realm
219233
----
220234
221235
This is needed, so that Tomcat will use configured JAAS realm with `BearerTokenLoginModule` instead of `tomcat-users.xml` file, which Hawtio uses on Tomcat by default.
236+
////
222237

223238
////
224239
// WildFly authentication is not yet supported.

modules/ROOT/pages/oidc.adoc

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
= OpenID Connect Integration
22

3-
Hawtio is already xref:keycloak.adoc[supporting Keycloak] as https://openid.net/specs/openid-connect-core-1_0.html#Terminology[OpenID Provider]. However, Keycloak https://www.keycloak.org/2022/02/adapter-deprecation[already announced] that the configuration methods used by Hawtio are deprecated.
3+
For a long time, Hawtio was xref:keycloak.adoc[supporting Keycloak] as https://openid.net/specs/openid-connect-core-1_0.html#Terminology[OpenID Provider]. However, Keycloak https://www.keycloak.org/2022/02/adapter-deprecation[already announced] that these configuration methods used by Hawtio are deprecated.
44

5-
Because https://openid.net/specs/openid-connect-core-1_0.html[OpenID Connect Core 1.0] is a widespread specification and standard method for distributed authentication (based on https://datatracker.ietf.org/doc/html/rfc6749[OAuth 2]), Hawtio 4 now supports generic OpenID authentication.
5+
Because https://openid.net/specs/openid-connect-core-1_0.html[OpenID Connect Core 1.0] is a widespread specification and standard method for distributed authentication (based on https://datatracker.ietf.org/doc/html/rfc6749[OAuth 2]), Hawtio 4 supports generic OpenID authentication. +
6+
This allows integration with any OpenID Connect implementations.
67

78
== Building blocks and terminology
89

@@ -20,12 +21,12 @@ Authorization Server:: The server that coordinates communication between a _clie
2021
+
2122
In OpenID Connect specification, the _authorization server_ is named _OpenID Provider (OP)_.
2223

23-
The main goal of OAuth2 and OpenID Connect it to allow applications to access APIs without using user credentials and switch to token exchange.
24+
The main goal of OAuth2 and OpenID Connect specifications is to allow applications to access APIs without using user credentials and switch to token exchange.
2425

2526
It is important to know how Hawtio maps to the above roles:
2627

27-
* Hawtio Client application is an OAuth2 _client_. User interacts with Hawtio web application which in turn communicates with Hawtio Server (backend) with https://jolokia.org/[Jolokia agent] running. Before accessing the Jolokia agent, Hawtio needs an OpenID Connect _access token_. To this end, Hawtio Client initiates OpenID Connect authentication process by redirecting user to _Authorization Server_.
28-
* Hawtio Server application is a JakartaEE application exposing a https://jolokia.org/[Jolokia Agent] API which authorizes user actions based on the content of an _access token_. Using OAuth2 terminology, Hawtio Server is a _Resource Server_.
28+
* Hawtio Client application is an OAuth2 _client_. User interacts with Hawtio web application which in turn communicates with Hawtio Server (backend) with a https://jolokia.org/[Jolokia Agent] running. Before accessing the Jolokia Agent, Hawtio needs an OpenID Connect _access token_. To this end, Hawtio Client initiates OpenID Connect authentication process by redirecting user to the _Authorization Server_.
29+
* Hawtio Server application is a JakartaEE application exposing a https://jolokia.org/[Jolokia Agent] API which authorizes user actions based on the content of an _access token_. Using OAuth2 terminology, Hawtio Server (and the Jolokia Agent it contains) is a _Resource Server_.
2930

3031
The below UML diagram present the big picture.
3132

@@ -36,22 +37,22 @@ The below UML diagram present the big picture.
3637
// "Authorization Server" -> "User (Browser)": show login page
3738
// "User (Browser)" -> "Authorization Server": authenticate
3839
// "Authorization Server" -> "Hawtio Client": OAuth2 code+token
39-
// "Hawtio Client" -> "Hawtio Server": access Jolokia with access token
40+
// "Hawtio Client" -> "Hawtio Server": access Jolokia Agent with access token
4041
// ....
4142
image::oidc-auth.png[]
4243

4344
The most important aspect is: Hawtio Client never deals with user credentials. User authenticates with Authorization Server and Hawtio Client only gets the access token used later to access Hawtio Server (and its Jolokia API).
4445

4546
== Generic OpenID Connect authentication in Hawtio
4647

47-
Hawtio 4 can be used with existing OpenID Connect providers (like Keycloak, Microsoft Entra ID, Auth0, ...) and uses these libraries to fullfill the task:
48+
Hawtio 4 can be used with existing OpenID Connect providers (like Keycloak, Microsoft Entra ID, Auth0, ...) and uses these libraries to fulfill the task:
4849

4950
* https://hc.apache.org/httpcomponents-client-4.5.x/[Apache HTTP Client 4] to implement HTTP communication from Hawtio Server to OpenID Connect provider (e.g., to retrieve information about public keys for token signature validation).
5051
* https://connect2id.com/products/nimbus-jose-jwt[Nimbus JOSE + JWT] library to manipulate and validate OpenID Connect / OAuth2 access tokens.
5152

52-
These libraries are included in Hawtio Server WAR, which means there's no need to install/deploy _any_ additional libraries (as it is the case with xref:keycloak.adoc[Keycloak specific configuration]).
53+
These libraries are included in Hawtio Server WAR, which means there's no need to install/deploy _any_ additional libraries (as it is the case with xref:keycloak.adoc[Keycloak legacy support]).
5354

54-
In order to configure Hawtio with external OpenID Connect provider, we need to provide one configuration file and point Hawtio to its location.
55+
In order to configure Hawtio with an external OpenID Connect provider, we need to provide one configuration file and point Hawtio to its location.
5556

5657
The system property that specifies the location of OIDC (OpenID Connect) configuration is `-Dhawtio.oidcConfig`, but in case it's not specified, a default location is checked. The defaults are:
5758

@@ -62,14 +63,18 @@ The system property that specifies the location of OIDC (OpenID Connect) configu
6263
* For Apache Artemis runtime, `${artemis.instance.etc}/hawtio-oidc.properties`
6364
* Falls back to `classpath:hawtio-oidc.properties` (for embedded Hawtio usage)
6465

65-
Unlike with xref:keycloak.adoc[Keycloak specific configuration], there's only one `*.properties` file needed that is used to configure all the aspects of OpenID Connect configuration. Here's the template:
66+
Unlike with xref:keycloak.adoc[Keycloak legacy configuration], there's only one `*.properties` file needed that is used to configure all the aspects of OpenID Connect configuration. Here's the template:
6667

6768
[source]
6869
----
6970
# OpenID Connect configuration required at client side
7071
72+
# Name of the OIDC configuration - used for display purposes when selecting authentication method in the browser
73+
name = Keycloak@localhost
74+
7175
# URL of OpenID Connect Provider - the URL after which ".well-known/openid-configuration" can be appended for
7276
# discovery purposes
77+
# if this property is unavailable, OIDC is not enabled
7378
provider = http://localhost:18080/realms/hawtio-demo
7479
# OpenID client identifier
7580
client_id = hawtio-client
@@ -93,8 +98,13 @@ oidc.cacheConfig = true
9398
# time in minutes to cache public keys from jwks_uri
9499
jwks.cacheTime = 60
95100
101+
# a path for a field in JWT payload that should be used as user identifier. Keycloak for example uses
102+
# preferred_username, but it may be other field. The value will be used as user/identity JAAS Principal
103+
oidc.userPath = preferred_username
104+
96105
# a path for an array of roles found in JWT payload. Property placeholders can be used for parameterized parts
97-
# of the path (like for Keycloak) - but only for properties from this particular file
106+
# of the path (like for Keycloak) - but only for properties from this particular file.
107+
# The value will be used as role JAAS Principal(s)
98108
# example for properly configured Entra ID token
99109
#oidc.rolesPath = roles
100110
# example for Keycloak with use-resource-role-mappings=true
@@ -129,6 +139,7 @@ http.readTimeout = 10000
129139

130140
This file configures several aspects of Hawtio+OpenID Connect:
131141

142+
* `name` property will be used at multi-authentication Hawtio login page
132143
* OAuth2 - configure the location of Authorization Server, client ID and several OpenID Connect related options
133144
* JWKS - cache time for public keys obtained from `jwks_uri`, which is the endpoint that exposes public keys used by the Authorization Server.
134145
* JWT token configuration - information about the _claim_ (a field in JSON Web Token) that contains roles associated with the authenticated user. We also allow to map roles as defined in the Authorization Server to the roles used by the application (Hawtio Server and Jolokia).
@@ -146,6 +157,16 @@ There's a system property that specifies the role class:
146157
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
147158
----
148159

160+
The user identity (indicated by `oidc.userPath` property) is used to find a field (a _claim_) in the JWT token to be interpreted as
161+
user identifier (as opposed to one of user's roles). With JAAS authentication, this identifier will be added as _user principal_. By default
162+
the class of user principal is `io.hawt.web.auth.UserPrincipal`, but it can be changed to other class. For example with Artemis:
163+
164+
----
165+
-Dhawtio.userPrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.UserPrincipal
166+
----
167+
168+
NOTE: Hawtio can analyze configure JAAS login modules and determine the role/user principal classes dynamically.
169+
149170
== Using Hawtio and OpenID Connect authentication with Keycloak
150171

151172
The simplest way to run Keycloak instance is using a container:
@@ -228,9 +249,17 @@ Then in the "Users" field we can select for example "admin" and click "Generated
228249
}
229250
----
230251

231-
Knowing the structure of JWT access token we can check if role _path_ is configured correctly:
252+
Knowing the structure of JWT access token we can check if role _path_ and user _path_ are configured correctly:
232253

233254
----
255+
# a path for a field in JWT payload that should be used as user identifier. Keycloak for example uses
256+
# preferred_username, but it may be other field. The value will be used as user/identity JAAS Principal
257+
oidc.userPath = preferred_username
258+
259+
# a path for an array of roles found in JWT payload. Property placeholders can be used for parameterized parts
260+
# of the path (like for Keycloak) - but only for properties from this particular file.
261+
# example for Keycloak with use-resource-role-mappings=true
262+
#oidc.rolesPath = resource_access.${client_id}.roles
234263
# example for Keycloak with use-resource-role-mappings=false
235264
oidc.rolesPath = realm_access.roles
236265
----
@@ -272,8 +301,12 @@ Here's the Hawtio configuration where `provider` is the base URL of your tenant
272301
----
273302
# OpenID Connect configuration required at client side
274303
304+
# Name of the OIDC configuration - used for display purposes when selecting authentication method in the browser
305+
name = Microsoft Entra ID
306+
275307
# URL of OpenID Connect Provider - the URL after which ".well-known/openid-configuration" can be appended for
276308
# discovery purposes
309+
# if this property is unavailable, OIDC is not enabled
277310
provider = https://login.microsoftonline.com/00000000-1111-2222-3333-444444444444/v2.0
278311
# OpenID client identifier
279312
client_id = 55555555-6666-7777-8888-999999999999
@@ -326,7 +359,7 @@ Let's summarize the configuration required in Entra ID.
326359
+
327360
image::entra-scope.png[]
328361
+
329-
This will create a reference'able `api://hawtio-server/Jolokia.Access` scope we will use later.
362+
This will create a referencable `api://hawtio-server/Jolokia.Access` scope we will use later.
330363
3. In "App roles" section for `hawtio-server` define any roles you want to assign to users within the scope of this client, for example:
331364
+
332365
image::entra-roles.png[]
@@ -394,7 +427,7 @@ For reference, here's the relevant JSON snippet of `hawtio-server` app registrat
394427
...
395428
----
396429

397-
Now the granted access token is no longer specific for Microsft Graph API _audience_. It is intended for `hawtio-server` - `aud` claim is the UUID of `hawtio-server` app registration and `appid` claim is the UUID of `hawtio-client` app registration:
430+
Now the granted access token is no longer specific for Microsoft Graph API _audience_. It is intended for `hawtio-server` - `aud` claim is the UUID of `hawtio-server` app registration and `appid` claim is the UUID of `hawtio-client` app registration:
398431

399432
[,json]
400433
----

modules/ROOT/pages/online/develop.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ The following script lets you apply the above environment variables to all the d
7474
$ ./scripts/disable-jolokia-auth.sh
7575
----
7676

77-
---
77+
'''

modules/ROOT/pages/online/kubernetes.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ otherwise:
9191
$ kubectl apply -k deploy/k8s/namespace/
9292
----
9393

94+
[#_deployment]
9495
== Deployment
9596

9697
There are two deployment modes you can choose from: **cluster** and **namespace**.

0 commit comments

Comments
 (0)