Skip to content

Commit

Permalink
Merge pull request #85 from IngoStrauch2020/feature/client_update_cli…
Browse files Browse the repository at this point in the history
…entauthenticatortype

Feature/client update clientauthenticatortype
  • Loading branch information
klg71 authored Sep 19, 2024
2 parents 7bee26a + 8329593 commit 68cb6d2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ repositories {
}

tasks {
val keycloakVersion = "25.0.0"
val keycloakVersion = "25.0.5"

named("build") {
dependsOn("buildDocker", ":docsbuild:buildDocs")
Expand Down Expand Up @@ -154,7 +154,7 @@ tasks {
register("execWindowsKeycloak") {
doLast {
ProcessBuilder(
"cmd", "/c", "kc.bat", "start-dev", "--http-port=18080", "--hostname-strict=false","--http-relative-path=/auth","--log-level=info", ">",
"cmd", "/c", "kc.bat", "start-dev", "--http-port=18080", "--http-management-port=18081", "--hostname-strict=false","--http-relative-path=/auth","--log-level=info", ">",
"output.txt"
).run {
directory(File("keycloak/keycloak-$keycloakVersion/bin"))
Expand Down
1 change: 1 addition & 0 deletions docsbuild/content/migrations/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Update a client
- surrogateAuthRequired: Boolean, optional, default=no change
- enabled: Boolean, optional, default=no change
- alwaysDisplayInConsole: Boolean, optional, default=no change
- clientAuthenticatorType: String, optional, default=no change
- attributes: Map<String, String>, optional, default=no change
- protocol: String, optional, default=no change
- redirectUris: List< String>, optional, default=no change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class UpdateClientAction(
private val surrogateAuthRequired: Boolean? = null,
private val enabled: Boolean? = null,
private val alwaysDisplayInConsole: Boolean? = null,
private val clientAuthenticatorType: String? = null,
private val attributes: Map<String, String>? = null,
private val protocol: String? = null,
private val redirectUris: List<String>? = null,
Expand All @@ -34,6 +35,13 @@ class UpdateClientAction(
private val fullScopeAllowed: Boolean? = null,
private val nodeReRegistrationTimeout: Int ?= null) : Action(realm) {

companion object {
@JvmStatic
val supportedClientAuthenticatorTypes = listOf(
"client-jwt", "client-secret", "client-secret-jwt", "client-x509"
)
}

private lateinit var oldClient: Client

@Suppress("ComplexMethod")
Expand All @@ -45,7 +53,7 @@ class UpdateClientAction(
surrogateAuthRequired ?: oldClient.surrogateAuthRequired,
enabled ?: oldClient.enabled,
alwaysDisplayInConsole ?: oldClient.alwaysDisplayInConsole,
oldClient.clientAuthenticatorType,
clientAuthenticatorType ?: oldClient.clientAuthenticatorType,
redirectUris ?: oldClient.redirectUris,
webOrigins ?: oldClient.webOrigins,
notBefore ?: oldClient.notBefore,
Expand Down Expand Up @@ -73,6 +81,13 @@ class UpdateClientAction(
)

override fun execute() {
if (clientAuthenticatorType != null && clientAuthenticatorType !in supportedClientAuthenticatorTypes) {
throw MigrationException(
"Client authenticator type '$clientAuthenticatorType' is not supported. " +
"Use one of: ${supportedClientAuthenticatorTypes.joinToString(", ")}"
)
}

if (!client.existsClient(clientId, realm())) {
throw MigrationException("Client with id: $clientId does not exist in realm: $realm!")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
id: update_client_clientauthenticatortype
author: klg71
realm: integ-test
changes:
- addSimpleClient:
clientId: testClientJwtAuth
- updateClient:
clientId: testClientJwtAuth
publicClient: false
clientAuthenticatorType: client-jwt
1 change: 1 addition & 0 deletions src/test/resources/keycloak-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ includes:
- path: changesets/40_add_identity_provider_mappers.yml
- path: changesets/41_delete_identity_provider_mappers.yml
- path: changesets/42_register_required_action.yml
- path: changesets/43_update_client_clientauthenticatortype.yml

0 comments on commit 68cb6d2

Please sign in to comment.