From daf7c7159791c95b57e14bdca7d1eb054d2b0329 Mon Sep 17 00:00:00 2001 From: AssahBismarkabah Date: Tue, 29 Oct 2024 16:15:01 +0100 Subject: [PATCH 01/10] feat Allow environment variables from existing secrets --- contrib/charts/keycloak-config-cli/Chart.yaml | 4 ++-- contrib/charts/keycloak-config-cli/templates/job.yaml | 11 ++++++++++- contrib/charts/keycloak-config-cli/values.yaml | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/contrib/charts/keycloak-config-cli/Chart.yaml b/contrib/charts/keycloak-config-cli/Chart.yaml index ed4207515..e93462fdd 100644 --- a/contrib/charts/keycloak-config-cli/Chart.yaml +++ b/contrib/charts/keycloak-config-cli/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: keycloak-config-cli description: Import JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak. home: https://github.com/adorsys/keycloak-config-cli -version: 6.1.7-SNAPSHOT -appVersion: 6.1.7-SNAPSHOT +version: 4.0.1 +appVersion: 4.0.1 maintainers: - name: jkroepke email: joe@adorsys.de diff --git a/contrib/charts/keycloak-config-cli/templates/job.yaml b/contrib/charts/keycloak-config-cli/templates/job.yaml index a6d04f1de..9b22f9d4c 100644 --- a/contrib/charts/keycloak-config-cli/templates/job.yaml +++ b/contrib/charts/keycloak-config-cli/templates/job.yaml @@ -54,7 +54,16 @@ spec: secretKeyRef: name: "{{ tpl .Values.existingSecret . }}" key: "{{ .Values.existingSecretKey }}" - {{- end }} + {{- end }} + {{- if .Values.existingSecrets }} + {{- range .Values.existingSecrets }} + - name: {{ .envVar }} + valueFrom: + secretKeyRef: + name: {{ .name }} + key: {{ .key }} + {{- end }} + {{- end }} {{- with .Values.containerSecurityContext }} securityContext: {{- toYaml . | nindent 12 }} diff --git a/contrib/charts/keycloak-config-cli/values.yaml b/contrib/charts/keycloak-config-cli/values.yaml index c8e371027..f46573690 100644 --- a/contrib/charts/keycloak-config-cli/values.yaml +++ b/contrib/charts/keycloak-config-cli/values.yaml @@ -55,6 +55,11 @@ podLabels: {} ## Extra Annotations to be added to pod podAnnotations: {} +# New section for existing secrets +existingSecrets: +# - name: my-existing-secret +# key: my-secret-key +# envVar: MY_ENV_VAR config: {} # : From c42dec8b40e62501bbd121661a451022d7fb1383 Mon Sep 17 00:00:00 2001 From: AssahBismarkabah Date: Tue, 29 Oct 2024 16:15:22 +0100 Subject: [PATCH 02/10] feat Allow environment variables from existing secrets --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0244bc3b8..62985bc76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ### Fixed +- Allow environment variables from existing secrets [#822](https://github.com/adorsys/keycloak-config-cli/issues/822) +### Fixed - Fix versioning in artifact to contain the correct keycloak version [#1097](https://github.com/adorsys/keycloak-config-cli/issues/1097) ### Fixed From d0f09aa627b91179d7730812ff6e87dd3003b7e1 Mon Sep 17 00:00:00 2001 From: AssahBismarkabah Date: Tue, 29 Oct 2024 16:38:59 +0100 Subject: [PATCH 03/10] fix build failure --- contrib/charts/keycloak-config-cli/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/charts/keycloak-config-cli/Chart.yaml b/contrib/charts/keycloak-config-cli/Chart.yaml index e93462fdd..ed4207515 100644 --- a/contrib/charts/keycloak-config-cli/Chart.yaml +++ b/contrib/charts/keycloak-config-cli/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: keycloak-config-cli description: Import JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak. home: https://github.com/adorsys/keycloak-config-cli -version: 4.0.1 -appVersion: 4.0.1 +version: 6.1.7-SNAPSHOT +appVersion: 6.1.7-SNAPSHOT maintainers: - name: jkroepke email: joe@adorsys.de From 66181f42b32047c3fb704cf03c57ab961f4cd8fa Mon Sep 17 00:00:00 2001 From: Calebasah Date: Tue, 5 Nov 2024 17:37:07 +0100 Subject: [PATCH 04/10] Modify RequiredActionsImportService --- .../keycloak/config/service/RequiredActionsImportService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/adorsys/keycloak/config/service/RequiredActionsImportService.java b/src/main/java/de/adorsys/keycloak/config/service/RequiredActionsImportService.java index 134e0339d..602c0db55 100644 --- a/src/main/java/de/adorsys/keycloak/config/service/RequiredActionsImportService.java +++ b/src/main/java/de/adorsys/keycloak/config/service/RequiredActionsImportService.java @@ -63,7 +63,7 @@ public void doImport(RealmImport realmImport) { List existingRequiredActions = requiredActionRepository.getAll(realmName); - if (importConfigProperties.getManaged().getClientScope() == ImportManagedPropertiesValues.FULL) { + if (importConfigProperties.getManaged().getRequiredAction() == ImportManagedPropertiesValues.FULL) { deleteRequiredActionsMissingInImport(realmName, requiredActions, existingRequiredActions); } From aefbb0dff84fcda7d1fb82309237c310356f5086 Mon Sep 17 00:00:00 2001 From: Calebasah Date: Wed, 6 Nov 2024 10:22:23 +0100 Subject: [PATCH 05/10] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62985bc76..4d4c9a245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Fix required action import handling for no-delete option [#834](https://github.com/adorsys/keycloak-config-cli/issues/834) + ### Fixed - Allow environment variables from existing secrets [#822](https://github.com/adorsys/keycloak-config-cli/issues/822) ### Fixed From 9d3c40d574627341d777f4eb50072f227493d91c Mon Sep 17 00:00:00 2001 From: AssahBismarkabah Date: Wed, 6 Nov 2024 15:36:40 +0100 Subject: [PATCH 06/10] improved logging for realm retrieval errors --- CHANGELOG.md | 2 ++ .../keycloak/config/service/checksum/ChecksumService.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62985bc76..01b306fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- improved logging for realm retrieval errors [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010) ### Fixed - Allow environment variables from existing secrets [#822](https://github.com/adorsys/keycloak-config-cli/issues/822) ### Fixed diff --git a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java index 735e4b14d..92f6956f8 100644 --- a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java +++ b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java @@ -52,6 +52,9 @@ public ChecksumService(RealmRepository realmRepository, ImportConfigProperties i public void doImport(RealmImport realmImport) { RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm()); + if (existingRealm == null) { + throw new InvalidImportException("The specified realm does not exist: " + realmImport.getRealm()); + } Map customAttributes = existingRealm.getAttributes(); String importChecksum = realmImport.getChecksum(); From 738c4cbab3a34043b70df4ba23f0662a41dfe97a Mon Sep 17 00:00:00 2001 From: AssahBismarkabah Date: Wed, 6 Nov 2024 16:17:44 +0100 Subject: [PATCH 07/10] fix test failures in workflow --- .../keycloak/config/service/checksum/ChecksumService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java index 92f6956f8..87bd7b21a 100644 --- a/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java +++ b/src/main/java/de/adorsys/keycloak/config/service/checksum/ChecksumService.java @@ -52,9 +52,6 @@ public ChecksumService(RealmRepository realmRepository, ImportConfigProperties i public void doImport(RealmImport realmImport) { RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm()); - if (existingRealm == null) { - throw new InvalidImportException("The specified realm does not exist: " + realmImport.getRealm()); - } Map customAttributes = existingRealm.getAttributes(); String importChecksum = realmImport.getChecksum(); @@ -67,6 +64,9 @@ public void doImport(RealmImport realmImport) { public boolean hasToBeUpdated(RealmImport realmImport) { RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm()); + if (existingRealm == null) { + throw new InvalidImportException("The specified realm does not exist: " + realmImport.getRealm()); + } Map customAttributes = existingRealm.getAttributes(); String readChecksum = customAttributes.get(getCustomAttributeKey(realmImport)); From b8bf02c1a6096c4887c1bd5306a954643f715544 Mon Sep 17 00:00:00 2001 From: Motouom Victoire Date: Fri, 8 Nov 2024 10:51:45 +0100 Subject: [PATCH 08/10] Add navigation menu to the README --- CHANGELOG.md | 1 + README.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b86cd91..17ae39286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- improved logging for realm retrieval errors [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010) ### Added - improved logging for realm retrieval errors [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010) ### Fixed diff --git a/README.md b/README.md index f69688c84..5344a7596 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,29 @@ [![codecov](https://codecov.io/gh/adorsys/keycloak-config-cli/branch/main/graph/badge.svg)](https://codecov.io/gh/adorsys/keycloak-config-cli) [![GitHub license](https://img.shields.io/github/license/adorsys/keycloak-config-cli)](https://github.com/adorsys/keycloak-config-cli/blob/main/LICENSE.txt) +# Table of Contents + +- [Config Files](#config-files) +- [Variable Substitution](#variable-substitution) + - [Supported Substitutions](#supported-substitutions) +- [Logging](#logging) + - [JSON Logging Support](#json-logging-support) + - [Log Level](#log-level) +- [Supported Features](#supported-features) +- [Compatibility with Keycloak](#compatibility-with-keycloak) +- [Build this Project](#build-this-project) +- [Run Integration Tests](#run-integration-tests) +- [Run this Project](#run-this-project) +- [Docker](#docker) +- [Helm](#helm) +- [Configuration](#configuration) + - [CLI Options / Environment Variables](#cli-options--environment-variables) + - [Keycloak Options](#keycloak-options) + - [Import Options](#import-options) + - [Spring Boot Options](#spring-boot-options) +- [Perform Release](#perform-release) +- [Commercial Support](#commercial-support) + # keycloak-config-cli keycloak-config-cli is a Keycloak utility to ensure the desired configuration state for a realm based on a JSON/YAML file. The format of the JSON/YAML file based on the export realm format. Store and handle the configuration files inside git just like normal code. A Keycloak restart isn't required to apply the configuration. From 36b79f1ff2a3ce1206b0916b01749a68e3d3034e Mon Sep 17 00:00:00 2001 From: Motouom Victoire Date: Fri, 8 Nov 2024 11:17:02 +0100 Subject: [PATCH 09/10] Applied changes requested. --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5344a7596..a7a60d7b7 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,7 @@ - [Config Files](#config-files) - [Variable Substitution](#variable-substitution) - - [Supported Substitutions](#supported-substitutions) - [Logging](#logging) - - [JSON Logging Support](#json-logging-support) - - [Log Level](#log-level) - [Supported Features](#supported-features) - [Compatibility with Keycloak](#compatibility-with-keycloak) - [Build this Project](#build-this-project) @@ -21,10 +18,6 @@ - [Docker](#docker) - [Helm](#helm) - [Configuration](#configuration) - - [CLI Options / Environment Variables](#cli-options--environment-variables) - - [Keycloak Options](#keycloak-options) - - [Import Options](#import-options) - - [Spring Boot Options](#spring-boot-options) - [Perform Release](#perform-release) - [Commercial Support](#commercial-support) @@ -114,6 +107,8 @@ Further development requirements - Java Development Kit (JDK) - Docker Desktop or an alternative replacement (e.g Rancher Desktop) +Before running `mvn verify`, you have to set the JAVA_HOME environment variable to prevent some test failures. + ```shell ./mvnw verify From e5b17a6c3e4365701567382be7eef0ebd11327ae Mon Sep 17 00:00:00 2001 From: Motouom Victoire Date: Fri, 8 Nov 2024 11:26:12 +0100 Subject: [PATCH 10/10] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17ae39286..4e0cacd7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -- improved logging for realm retrieval errors [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010) +### Added +- Added Navigation in the readme [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010) ### Added - improved logging for realm retrieval errors [#1010](https://github.com/adorsys/keycloak-config-cli/issues/1010) ### Fixed