File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
src/main/java/com/hawk/keycloak/util Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -184,13 +184,14 @@ Required roles: `hawk-view-cache-buster`
184
184
` /realms/{realm}/hawk/connection-info `
185
185
186
186
This endpoint returns information about the connection to the keycloak server required
187
- for a smooth client experience.
187
+ for a smooth client experience. Note, to use this endpoint the requesting client MUST have a service account.
188
188
189
189
The response contains the following fields:
190
190
* keycloakVersion - The version of the keycloak server (Used for compatibility checks on the client side)
191
191
* extensionVersion - The version of the hawk keycloak extension
192
192
* clientId - The client id of the client that requested the endpoint
193
193
* clientUuid - The uuid of the client that requested the endpoint
194
+ * clientServiceAccountUuid - The uuid of the service account of the client that requested the endpoint
194
195
195
196
Required roles ` hawk-client `
196
197
Original file line number Diff line number Diff line change 4
4
import com .hawk .keycloak .util .model .ConnectionInfo ;
5
5
import lombok .RequiredArgsConstructor ;
6
6
import org .keycloak .common .Version ;
7
+ import org .keycloak .models .ClientModel ;
7
8
import org .keycloak .models .KeycloakSession ;
8
9
9
10
@ RequiredArgsConstructor
@@ -14,11 +15,18 @@ public class ConnectionInfoRequestHandler {
14
15
public ConnectionInfo handleRequest () {
15
16
auth .requireHawkClientRole ();
16
17
18
+ ClientModel client = session .getContext ().getClient ();
19
+
20
+ if (!client .isServiceAccountsEnabled ()){
21
+ throw new RuntimeException ("Service accounts are not enabled for this client, but this is required for the clients to work well" );
22
+ }
23
+
17
24
return new ConnectionInfo (
18
25
Version .VERSION ,
19
26
VersionInfo .getPackageVersion (),
20
- session .getContext ().getClient ().getClientId (),
21
- session .getContext ().getClient ().getId ()
27
+ client .getClientId (),
28
+ client .getId (),
29
+ session .users ().getServiceAccount (client ).getId ()
22
30
);
23
31
}
24
32
}
Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ public class ConnectionInfo {
10
10
private final String extensionVersion ;
11
11
private final String clientId ;
12
12
private final String clientUuid ;
13
+ private final String clientServiceAccountUuid ;
13
14
}
You can’t perform that action at this time.
0 commit comments