Merge pull request #51 from Ma27/path-type
module: prohibit store-paths for environmentFile
This commit is contained in:
commit
618330bee6
3 changed files with 28 additions and 16 deletions
11
module.nix
11
module.nix
|
|
@ -44,6 +44,11 @@ let
|
||||||
;
|
;
|
||||||
|
|
||||||
settingsFormat = pkgs.formats.yaml { };
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
|
|
||||||
|
pathToSecret = types.pathWith {
|
||||||
|
inStore = false;
|
||||||
|
absolute = true;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services = {
|
options.services = {
|
||||||
|
|
@ -81,7 +86,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
environmentFile = mkOption {
|
environmentFile = mkOption {
|
||||||
type = types.nullOr types.path;
|
type = types.nullOr pathToSecret;
|
||||||
default = null;
|
default = null;
|
||||||
example = "/run/secrets/authentik/authentik-env";
|
example = "/run/secrets/authentik/authentik-env";
|
||||||
description = ''
|
description = ''
|
||||||
|
|
@ -105,7 +110,7 @@ in
|
||||||
enable = mkEnableOption "authentik LDAP outpost";
|
enable = mkEnableOption "authentik LDAP outpost";
|
||||||
|
|
||||||
environmentFile = mkOption {
|
environmentFile = mkOption {
|
||||||
type = types.nullOr types.path;
|
type = types.nullOr pathToSecret;
|
||||||
default = null;
|
default = null;
|
||||||
example = "/run/secrets/authentik-ldap/authentik-ldap-env";
|
example = "/run/secrets/authentik-ldap/authentik-ldap-env";
|
||||||
description = ''
|
description = ''
|
||||||
|
|
@ -128,7 +133,7 @@ in
|
||||||
enable = mkEnableOption "authentik RADIUS outpost";
|
enable = mkEnableOption "authentik RADIUS outpost";
|
||||||
|
|
||||||
environmentFile = mkOption {
|
environmentFile = mkOption {
|
||||||
type = types.nullOr types.path;
|
type = types.nullOr pathToSecret;
|
||||||
default = null;
|
default = null;
|
||||||
example = "/run/secrets/authentik-radius/authentik-radius-env";
|
example = "/run/secrets/authentik-radius/authentik-radius-env";
|
||||||
description = ''
|
description = ''
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,6 @@
|
||||||
authentik-version,
|
authentik-version,
|
||||||
nixosModules,
|
nixosModules,
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
# use a root-owned EnvironmentFile in production instead (services.authentik.environmentFile)
|
|
||||||
authentik-env = pkgs.writeText "authentik-test-secret-env" ''
|
|
||||||
AUTHENTIK_SECRET_KEY=thissecretwillbeinthenixstore
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
pkgs.nixosTest {
|
pkgs.nixosTest {
|
||||||
name = "authentik";
|
name = "authentik";
|
||||||
nodes = {
|
nodes = {
|
||||||
|
|
@ -23,9 +17,18 @@ pkgs.nixosTest {
|
||||||
"${pkgs.path}/nixos/tests/common/x11.nix"
|
"${pkgs.path}/nixos/tests/common/x11.nix"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Keep in mind that the secret still ends up in the store and is world-readable because the
|
||||||
|
# systemd-tmpfiles config lands in the store.
|
||||||
|
# This is just a trick to not pass a store-path (which is prohibited) to `environmentFile`
|
||||||
|
# without having to integrate secret managers like agenix or sops-nix into the test.
|
||||||
|
# Don't do this in production.
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"f /etc/authentik.env 0700 root root - AUTHENTIK_SECRET_KEY=notastorepath"
|
||||||
|
];
|
||||||
|
|
||||||
services.authentik = {
|
services.authentik = {
|
||||||
enable = true;
|
enable = true;
|
||||||
environmentFile = authentik-env;
|
environmentFile = "/etc/authentik.env";
|
||||||
nginx = {
|
nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
host = "localhost";
|
host = "localhost";
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let
|
let
|
||||||
# use a root-owned EnvironmentFile in production instead (services.authentik.environmentFile)
|
|
||||||
authentik-env = pkgs.writeText "authentik-test-secret-env" ''
|
|
||||||
AUTHENTIK_SECRET_KEY=thissecretwillbeinthenixstore
|
|
||||||
'';
|
|
||||||
|
|
||||||
customWelcome = "Welcome to custom authentik";
|
customWelcome = "Welcome to custom authentik";
|
||||||
|
|
||||||
# creates a new scope using python 3.12 for mkPoetryEnv
|
# creates a new scope using python 3.12 for mkPoetryEnv
|
||||||
|
|
@ -61,9 +56,18 @@ pkgs.nixosTest {
|
||||||
"${pkgs.path}/nixos/tests/common/x11.nix"
|
"${pkgs.path}/nixos/tests/common/x11.nix"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Keep in mind that the secret still ends up in the store and is world-readable because the
|
||||||
|
# systemd-tmpfiles config lands in the store.
|
||||||
|
# This is just a trick to not pass a store-path (which is prohibited) to `environmentFile`
|
||||||
|
# without having to integrate secret managers like agenix or sops-nix into the test.
|
||||||
|
# Don't do this in production.
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"f /etc/authentik.env 0700 root root - AUTHENTIK_SECRET_KEY=notastorepath"
|
||||||
|
];
|
||||||
|
|
||||||
services.authentik = {
|
services.authentik = {
|
||||||
enable = true;
|
enable = true;
|
||||||
environmentFile = authentik-env;
|
environmentFile = "/etc/authentik.env";
|
||||||
nginx = {
|
nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
host = "localhost";
|
host = "localhost";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue