Skip to content

Commit

Permalink
feat: make use of client-credentials in the keycloak admin client
Browse files Browse the repository at this point in the history
BREAKING CHANGE: username password combination in the keycloak admin client is no longer supported
  • Loading branch information
dnlkoch committed Dec 23, 2024
1 parent 117d2b7 commit ae42666
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 22 deletions.
5 changes: 2 additions & 3 deletions shogun-boot/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ spring:
keycloak:
enabled: true
server-url: https://localhost/auth
username: admin
password: shogun
master-realm: master
admin-client-id: admin-cli
admin-client-secret: supersecret
realm: SHOGun
client-id: shogun-boot
principal-attribute: preferred_username
disableHostnameVerification: true
disable-hostname-verification: true

upload:
basePath: /data
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static org.keycloak.OAuth2Constants.CLIENT_CREDENTIALS;

/**
* Credits to https://stackoverflow.com/questions/57787768/issues-running-example-keycloak-spring-boot-app
*/
Expand All @@ -47,9 +49,9 @@ public Keycloak keycloakAdminClient() {
return KeycloakBuilder.builder()
.serverUrl(keycloakProperties.getServerUrl())
.realm(keycloakProperties.getMasterRealm())
.username(keycloakProperties.getUsername())
.password(keycloakProperties.getPassword())
.clientId(keycloakProperties.getAdminClientId())
.clientSecret(keycloakProperties.getAdminClientSecret())
.grantType(CLIENT_CREDENTIALS)
.resteasyClient(restClient)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public class KeycloakProperties {

private String serverUrl;

private String username;

private String password;

private String masterRealm;

private String adminClientId;

private String adminClientSecret;

private String realm;

private String clientId;
Expand Down
7 changes: 3 additions & 4 deletions shogun-config/src/main/resources/application-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,13 @@ springdoc:
keycloak:
enabled: true
server-url: https://${KEYCLOAK_HOST:shogun-keycloak}/auth
username: admin
password: shogun
master-realm: master
master-realm: SHOGun
admin-client-id: admin-cli
admin-client-secret: ${KEYCLOAK_ADMIN_CLIENT_SECRET}
realm: SHOGun
client-id: shogun-boot
principal-attribute: preferred_username
disableHostnameVerification: true
disable-hostname-verification: true
extract-roles-from-resource: true
extract-roles-from-realm: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ interceptor:
keycloak:
enabled: true
server-url: https://${KEYCLOAK_HOST:shogun-keycloak}/auth
username: admin
password: shogun
master-realm: master
admin-client-id: admin-cli
admin-client-secret: ${KEYCLOAK_ADMIN_CLIENT_SECRET}
realm: SHOGun
client-id: shogun-boot
principal-attribute: preferred_username
disableHostnameVerification: true
disable-hostname-verification: true
5 changes: 2 additions & 3 deletions shogun-proxy/src/main/resources/application-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ shogun-proxy:
keycloak:
enabled: true
server-url: https://${KEYCLOAK_HOST:shogun-keycloak}/auth
username: admin
password: shogun
master-realm: master
admin-client-id: admin-cli
admin-client-secret: ${KEYCLOAK_ADMIN_CLIENT_SECRET}
realm: SHOGun
client-id: shogun-boot
principal-attribute: preferred_username
disableHostnameVerification: true
disable-hostname-verification: true
5 changes: 2 additions & 3 deletions shogun-proxy/src/test/resources/application-proxy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
keycloak:
enabled: false
server-url: https://localhost/auth
username: admin
password: shogun
master-realm: master
admin-client-id: admin-cli
admin-client-secret: supersecret
realm: SHOGun
client-id: shogun-boot
principal-attribute: preferred_username
disableHostnameVerification: true
disable-hostname-verification: true

spring:
session:
Expand Down

0 comments on commit ae42666

Please sign in to comment.