Skip to content

Commit 6069dde

Browse files
committed
nixos/keycloak: make initialAdminPassword optional
1 parent 937d396 commit 6069dde

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

nixos/modules/services/web-apps/keycloak.nix

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,14 @@ in
249249
package = mkPackageOption pkgs "keycloak" { };
250250

251251
initialAdminPassword = mkOption {
252-
type = str;
253-
default = "changeme";
252+
type = nullOr str;
253+
default = null;
254254
description = ''
255-
Initial password set for the `admin`
256-
user. The password is not stored safely and should be changed
255+
Initial password set for the temporary `admin` user.
256+
The password is not stored safely and should be changed
257257
immediately in the admin panel.
258+
259+
See [Admin bootstrap and recovery](https://www.keycloak.org/server/bootstrap-admin-recovery) for details.
258260
'';
259261
};
260262

@@ -620,6 +622,9 @@ in
620622
environment = {
621623
KC_HOME_DIR = "/run/keycloak";
622624
KC_CONF_DIR = "/run/keycloak/conf";
625+
} // lib.optionalAttrs (cfg.initialAdminPassword != null) {
626+
KC_BOOTSTRAP_ADMIN_USERNAME = "admin";
627+
KC_BOOTSTRAP_ADMIN_PASSWORD = cfg.initialAdminPassword;
623628
};
624629
serviceConfig = {
625630
LoadCredential =
@@ -660,8 +665,6 @@ in
660665
mkdir -p /run/keycloak/ssl
661666
cp $CREDENTIALS_DIRECTORY/ssl_{cert,key} /run/keycloak/ssl/
662667
'' + ''
663-
export KC_BOOTSTRAP_ADMIN_USERNAME=admin
664-
export KC_BOOTSTRAP_ADMIN_PASSWORD=${escapeShellArg cfg.initialAdminPassword}
665668
kc.sh --verbose start --optimized
666669
'';
667670
};

0 commit comments

Comments
 (0)