Skip to content

Commit

Permalink
Merge pull request #318814 from NickCao/keycloak
Browse files Browse the repository at this point in the history
keycloak: 24.0.5 -> 25.0.1
  • Loading branch information
leona-ya authored Jun 22, 2024
2 parents 343b3d4 + 0360d42 commit 6311a7a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion nixos/doc/manual/release-notes/rl-2205.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ In addition to numerous new and upgraded packages, this release has the followin

The new names are as follows:
- `bindAddress`: [`services.keycloak.settings.http-host`](#opt-services.keycloak.settings.http-host)
- `forceBackendUrlToFrontendUrl`: [`services.keycloak.settings.hostname-strict-backchannel`](#opt-services.keycloak.settings.hostname-strict-backchannel)
- `forceBackendUrlToFrontendUrl`: `services.keycloak.settings.hostname-strict-backchannel`
- `httpPort`: [`services.keycloak.settings.http-port`](#opt-services.keycloak.settings.http-port)
- `httpsPort`: [`services.keycloak.settings.https-port`](#opt-services.keycloak.settings.https-port)

Expand Down
3 changes: 3 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
services.portunus.ldap.package = pkgs.openldap.override { libxcrypt = pkgs.libxcrypt-legacy; };
```

- `keycloak` was updated to version 25, which introduces new hostname related options.
See [Upgrading Guide](https://www.keycloak.org/docs/25.0.1/upgrading/#migrating-to-25-0-0) for instructions.

- The `tracy` package no longer works on X11, since it's moved to Wayland
support, which is the intended default behavior by Tracy maintainers.
X11 users have to switch to the new package `tracy-x11`.
Expand Down
12 changes: 5 additions & 7 deletions nixos/modules/services/web-apps/keycloak.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ to `/auth`. See the option description
for more details.
:::

[](#opt-services.keycloak.settings.hostname-strict-backchannel)
determines whether Keycloak should force all requests to go
through the frontend URL. By default,
Keycloak allows backend requests to
instead use its local hostname or IP address and may also
advertise it to clients through its OpenID Connect Discovery
endpoint.
[](#opt-services.keycloak.settings.hostname-backchannel-dynamic)
Keycloak has the capability to offer a separate URL for backchannel requests,
enabling internal communication while maintaining the use of a public URL
for frontchannel requests. Moreover, the backchannel is dynamically
resolved based on incoming headers endpoint.

For more information on hostname configuration, see the [Hostname
section of the Keycloak Server Installation and Configuration
Expand Down
28 changes: 16 additions & 12 deletions nixos/modules/services/web-apps/keycloak.nix
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ in
};

hostname = mkOption {
type = nullOr str;
default = null;
type = str;
example = "keycloak.example.com";
description = ''
The hostname part of the public URL used as base for
Expand All @@ -340,16 +339,13 @@ in
'';
};

hostname-strict-backchannel = mkOption {
hostname-backchannel-dynamic = mkOption {
type = bool;
default = false;
example = true;
description = ''
Whether Keycloak should force all requests to go
through the frontend URL. By default, Keycloak allows
backend requests to instead use its local hostname or
IP address and may also advertise it to clients
through its OpenID Connect Discovery endpoint.
Enables dynamic resolving of backchannel URLs,
including hostname, scheme, port and context path.
See <https://www.keycloak.org/server/hostname>
for more information about hostname configuration.
Expand Down Expand Up @@ -482,12 +478,20 @@ in
message = "Setting up a local PostgreSQL db for Keycloak requires `standard_conforming_strings` turned on to work reliably";
}
{
assertion = cfg.settings.hostname != null || cfg.settings.hostname-url or null != null;
message = "Setting the Keycloak hostname is required, see `services.keycloak.settings.hostname`";
assertion = cfg.settings.hostname-url or null == null;
message = ''
The option `services.keycloak.settings.hostname-url' has been removed.
Set `services.keycloak.settings.hostname' instead.
See [New Hostname options](https://www.keycloak.org/docs/25.0.0/upgrading/#new-hostname-options) for details.
'';
}
{
assertion = !(cfg.settings.hostname != null && cfg.settings.hostname-url or null != null);
message = "`services.keycloak.settings.hostname` and `services.keycloak.settings.hostname-url` are mutually exclusive";
assertion = cfg.settings.hostname-strict-backchannel or null == null;
message = ''
The option `services.keycloak.settings.hostname-strict-backchannel' has been removed.
Set `services.keycloak.settings.hostname-backchannel-dynamic' instead.
See [New Hostname options](https://www.keycloak.org/docs/25.0.0/upgrading/#new-hostname-options) for details.
'';
}
];

Expand Down
9 changes: 0 additions & 9 deletions nixos/tests/keycloak.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ let
};
plugins = with config.services.keycloak.package.plugins; [
keycloak-discord
keycloak-metrics-spi
];
};
environment.systemPackages = with pkgs; [
Expand Down Expand Up @@ -122,14 +121,6 @@ let
| jq -r '"Authorization: bearer " + .access_token' >admin_auth_header
""")
# Register the metrics SPI
keycloak.succeed(
"""${pkgs.jre}/bin/keytool -import -alias snakeoil -file ${certs.ca.cert} -storepass aaaaaa -keystore cacert.jks -noprompt""",
"""KC_OPTS='-Djavax.net.ssl.trustStore=cacert.jks -Djavax.net.ssl.trustStorePassword=aaaaaa' kcadm.sh config credentials --server '${frontendUrl}' --realm master --user admin --password "$(<${adminPasswordFile})" """,
"""KC_OPTS='-Djavax.net.ssl.trustStore=cacert.jks -Djavax.net.ssl.trustStorePassword=aaaaaa' kcadm.sh update events/config -s 'eventsEnabled=true' -s 'adminEventsEnabled=true' -s 'eventsListeners+=metrics-listener'""",
"""curl -sSf '${frontendUrl}/realms/master/metrics' | grep '^keycloak_admin_event_UPDATE'"""
)
# Publish the realm, including a test OIDC client and user
keycloak.succeed(
"curl -sSf -H @admin_auth_header -X POST -H 'Content-Type: application/json' -d @${realmDataJson} '${frontendUrl}/admin/realms/'"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/servers/keycloak/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ let
'';
in stdenv.mkDerivation rec {
pname = "keycloak";
version = "24.0.5";
version = "25.0.1";

src = fetchzip {
url = "https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-${version}.zip";
hash = "sha256-lf1miVEGQvPbmlOZMCXUyX/pKE+JoJFawhjVEPJDJ6s=";
hash = "sha256-gwnBCH65s8KGca2FNBxfBfNKox9OFTN3oEAPcYhSx9o=";
};

nativeBuildInputs = [ makeWrapper jre ];
Expand Down

0 comments on commit 6311a7a

Please sign in to comment.