Skip to content

Commit 5f821de

Browse files
authored
keycloak: 25.0.6 -> 26.0.0 (#346439)
2 parents 2996f32 + 6069dde commit 5f821de

File tree

3 files changed

+27
-37
lines changed

3 files changed

+27
-37
lines changed

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

Lines changed: 20 additions & 29 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

@@ -351,35 +353,12 @@ in
351353
for more information about hostname configuration.
352354
'';
353355
};
354-
355-
proxy = mkOption {
356-
type = enum [ "edge" "reencrypt" "passthrough" "none" ];
357-
default = "none";
358-
example = "edge";
359-
description = ''
360-
The proxy address forwarding mode if the server is
361-
behind a reverse proxy.
362-
363-
- `edge`:
364-
Enables communication through HTTP between the
365-
proxy and Keycloak.
366-
- `reencrypt`:
367-
Requires communication through HTTPS between the
368-
proxy and Keycloak.
369-
- `passthrough`:
370-
Enables communication through HTTP or HTTPS between
371-
the proxy and Keycloak.
372-
373-
See <https://www.keycloak.org/server/reverseproxy> for more information.
374-
'';
375-
};
376356
};
377357
};
378358

379359
example = literalExpression ''
380360
{
381361
hostname = "keycloak.example.com";
382-
proxy = "reencrypt";
383362
https-key-store-file = "/path/to/file";
384363
https-key-store-password = { _secret = "/run/keys/store_password"; };
385364
}
@@ -497,6 +476,16 @@ in
497476
See [New Hostname options](https://www.keycloak.org/docs/25.0.0/upgrading/#new-hostname-options) for details.
498477
'';
499478
}
479+
{
480+
assertion = cfg.settings.proxy or null == null;
481+
message = ''
482+
The option `services.keycloak.settings.proxy' has been removed.
483+
Set `services.keycloak.settings.proxy-headers` in combination
484+
with other hostname options as needed instead.
485+
See [Proxy option removed](https://www.keycloak.org/docs/latest/upgrading/index.html#proxy-option-removed)
486+
for more information.
487+
'';
488+
}
500489
];
501490

502491
environment.systemPackages = [ keycloakBuild ];
@@ -633,6 +622,9 @@ in
633622
environment = {
634623
KC_HOME_DIR = "/run/keycloak";
635624
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;
636628
};
637629
serviceConfig = {
638630
LoadCredential =
@@ -658,6 +650,7 @@ in
658650
659651
ln -s ${themesBundle} /run/keycloak/themes
660652
ln -s ${keycloakBuild}/providers /run/keycloak/
653+
ln -s ${keycloakBuild}/lib /run/keycloak/
661654
662655
install -D -m 0600 ${confFile} /run/keycloak/conf/keycloak.conf
663656
@@ -672,8 +665,6 @@ in
672665
mkdir -p /run/keycloak/ssl
673666
cp $CREDENTIALS_DIRECTORY/ssl_{cert,key} /run/keycloak/ssl/
674667
'' + ''
675-
export KEYCLOAK_ADMIN=admin
676-
export KEYCLOAK_ADMIN_PASSWORD=${escapeShellArg cfg.initialAdminPassword}
677668
kc.sh --verbose start --optimized
678669
'';
679670
};

nixos/tests/keycloak.nix

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ let
2020

2121
nodes = {
2222
keycloak = { config, ... }: {
23+
virtualisation.memorySize = 2047;
24+
2325
security.pki.certificateFiles = [
2426
certs.ca.cert
2527
];
@@ -48,8 +50,7 @@ let
4850
];
4951
};
5052
environment.systemPackages = with pkgs; [
51-
xmlstarlet
52-
html-tidy
53+
htmlq
5354
jq
5455
];
5556
};
@@ -151,16 +152,14 @@ let
151152
# post url.
152153
keycloak.succeed(
153154
"curl -sSf -c cookie '${frontendUrl}/realms/${realm.realm}/protocol/openid-connect/auth?client_id=${client.name}&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+email&response_type=code&response_mode=query&nonce=qw4o89g3qqm' >login_form",
154-
"tidy -asxml -q -m login_form || true",
155-
"xml sel -T -t -m \"_:html/_:body/_:div/_:div/_:div/_:div/_:div/_:div/_:form[@id='kc-form-login']\" -v @action login_form >form_post_url",
155+
"htmlq '#kc-form-login' --attribute action --filename login_form --output form_post_url"
156156
)
157157
158158
# Post the login form and save the response. Once again tidy up
159159
# the HTML, then extract the authorization code.
160160
keycloak.succeed(
161161
"curl -sSf -L -b cookie -d 'username=${user.username}' -d 'password=${password}' -d 'credentialId=' \"$(<form_post_url)\" >auth_code_html",
162-
"tidy -asxml -q -m auth_code_html || true",
163-
"xml sel -T -t -m \"_:html/_:body/_:div/_:div/_:div/_:div/_:div/_:input[@id='code']\" -v @value auth_code_html >auth_code",
162+
"htmlq '#code' --attribute value --filename auth_code_html --output auth_code"
164163
)
165164
166165
# Exchange the authorization code for an access token.

pkgs/servers/keycloak/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ let
1818
'';
1919
in stdenv.mkDerivation rec {
2020
pname = "keycloak";
21-
version = "25.0.6";
21+
version = "26.0.0";
2222

2323
src = fetchzip {
2424
url = "https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-${version}.zip";
25-
hash = "sha256-1VHixRgErao/1ZEJv+rlnNmUd2NT35X89D8wuUhYF08=";
25+
hash = "sha256-BWkF5iiR4J7NskrJUFmlP0N+HEkyZLnLJbMmbXCROxo=";
2626
};
2727

2828
nativeBuildInputs = [ makeWrapper jre ];

0 commit comments

Comments
 (0)