Skip to content

Commit

Permalink
nixos/kanidm: rename options to match upstream nomenclature
Browse files Browse the repository at this point in the history
  • Loading branch information
oddlama committed Dec 22, 2024
1 parent 8dacc3a commit c1a2646
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
After you run ALTER EXTENSION, you must run [this SQL script](https://github.com/timescale/timescaledb-extras/blob/master/utils/2.15.X-fix_hypertable_foreign_keys.sql). For more details, see the following pull requests [#6797](https://github.com/timescale/timescaledb/pull/6797).
PostgreSQL 13 is no longer supported in TimescaleDB v2.16.

- Some `kanidm` provisioning options were renamed to match upstream nomenclature. In particular, this affects the two oauth2 options `originUrl` and `originLanding` which are now called `redirectUri` and `landingUrl` respectively.

- Support for CUDA 10 has been dropped, as announced in the 24.11 release notes.

- `zammad` has had its support for MySQL removed, since it was never working correctly and is now deprecated upstream. Check the [migration guide](https://docs.zammad.org/en/latest/appendix/migrate-to-postgresql.html) for how to convert your database to PostgreSQL.
Expand Down
41 changes: 35 additions & 6 deletions nixos/modules/services/security/kanidm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ let
hasPrefix
isStorePath
last
mapAttrs
mapAttrsToList
mkEnableOption
mkForce
mkIf
mkMerge
mkOption
mkPackageOption
mkRenamedOptionModule
optional
optionals
optionalString
optionals
splitString
subtractLists
types
Expand Down Expand Up @@ -139,9 +141,31 @@ let

filterPresent = filterAttrs (_: v: v.present);

provisionStateJson = pkgs.writeText "provision-state.json" (
builtins.toJSON { inherit (cfg.provision) groups persons systems; }
);
provisionStateJson =
let
# Make sure the resulting state json does not contain any of our renamed options.
applyRenames =
state:
state
// {
systems.oauth2 = mapAttrs (
_: x:
removeAttrs x [
"redirectUri"
"landingUrl"
]
// {
originUrl = x.redirectUri;
originLanding = x.landingUrl;
}
) state.systems.oauth2;
};
in
pkgs.writeText "provision-state.json" (
builtins.toJSON {
inherit (applyRenames cfg.provision) groups persons systems;
}
);

# Only recover the admin account if a password should explicitly be provisioned
# for the account. Otherwise it is not needed for provisioning.
Expand Down Expand Up @@ -502,6 +526,11 @@ in
default = { };
type = types.attrsOf (
types.submodule {
imports = [
(mkRenamedOptionModule [ "originUrl" ] [ "redirectUri" ])
(mkRenamedOptionModule [ "originLanding" ] [ "landingUrl" ])
];

options = {
present = mkPresentOption "oauth2 resource server";

Expand All @@ -517,7 +546,7 @@ in
example = "Some Service";
};

originUrl = mkOption {
redirectUri = mkOption {
description = "The redirect URL of the service. These need to exactly match the OAuth2 redirect target";
type =
let
Expand All @@ -527,7 +556,7 @@ in
example = "https://someservice.example.com/auth/login";
};

originLanding = mkOption {
landingUrl = mkOption {
description = "When redirecting from the Kanidm Apps Listing page, some linked applications may need to land on a specific page to trigger oauth2/oidc interactions.";
type = types.str;
example = "https://someservice.example.com/home";
Expand Down
24 changes: 12 additions & 12 deletions nixos/tests/kanidm-provisioning.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ import ./make-test-python.nix (
groups.service1-admin = { };
systems.oauth2.service1 = {
displayName = "Service One";
originUrl = "https://one.example.com/";
originLanding = "https://one.example.com/landing";
redirectUri = "https://one.example.com/";
landingUrl = "https://one.example.com/landing";
basicSecretFile = pkgs.writeText "bs-service1" "very-strong-secret-for-service1";
scopeMaps.service1-access = [
"openid"
Expand All @@ -111,8 +111,8 @@ import ./make-test-python.nix (

systems.oauth2.service2 = {
displayName = "Service Two";
originUrl = "https://two.example.com/";
originLanding = "https://landing2.example.com/";
redirectUri = "https://two.example.com/";
landingUrl = "https://landing2.example.com/";
# Test not setting secret
# basicSecretFile =
allowInsecureClientDisablePkce = true;
Expand Down Expand Up @@ -159,11 +159,11 @@ import ./make-test-python.nix (
systems.oauth2.service1 = {
displayName = "Service One (changed)";
# multiple origin urls
originUrl = [
redirectUri = [
"https://changed-one.example.com/"
"https://changed-one.example.org/"
];
originLanding = "https://changed-one.example.com/landing-changed";
landingUrl = "https://changed-one.example.com/landing-changed";
basicSecretFile = pkgs.writeText "bs-service1" "changed-very-strong-secret-for-service1";
scopeMaps.service1-access = [
"openid"
Expand All @@ -178,8 +178,8 @@ import ./make-test-python.nix (

systems.oauth2.service2 = {
displayName = "Service Two (changed)";
originUrl = "https://changed-two.example.com/";
originLanding = "https://changed-landing2.example.com/";
redirectUri = "https://changed-two.example.com/";
landingUrl = "https://changed-landing2.example.com/";
# Test not setting secret
# basicSecretFile =
allowInsecureClientDisablePkce = false;
Expand Down Expand Up @@ -210,8 +210,8 @@ import ./make-test-python.nix (
groups.service1-admin = { };
systems.oauth2.service1 = {
displayName = "Service One (changed)";
originUrl = "https://changed-one.example.com/";
originLanding = "https://changed-one.example.com/landing-changed";
redirectUri = "https://changed-one.example.com/";
landingUrl = "https://changed-one.example.com/landing-changed";
basicSecretFile = pkgs.writeText "bs-service1" "changed-very-strong-secret-for-service1";
# Removing maps requires setting them to the empty list
scopeMaps.service1-access = [ ];
Expand All @@ -220,8 +220,8 @@ import ./make-test-python.nix (

systems.oauth2.service2 = {
displayName = "Service Two (changed)";
originUrl = "https://changed-two.example.com/";
originLanding = "https://changed-landing2.example.com/";
redirectUri = "https://changed-two.example.com/";
landingUrl = "https://changed-landing2.example.com/";
};
};
};
Expand Down

0 comments on commit c1a2646

Please sign in to comment.