mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
fix(postgresql): host auth
This commit is contained in:
parent
31528db499
commit
a8cd175500
1 changed files with 7 additions and 1 deletions
|
|
@ -6,8 +6,14 @@
|
|||
inherit (lib.modules) mkIf mkMerge mkOptionDefault mkDefault;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.lists) any;
|
||||
inherit (lib.strings) hasInfix;
|
||||
inherit (config) networking;
|
||||
cfg = config.services.postgresql;
|
||||
formatHost = host:
|
||||
if hasInfix "/" host then host
|
||||
else if hasInfix ":" host then "${host}/128"
|
||||
else if hasInfix "." host then "${host}/32"
|
||||
else throw "unsupported IP address ${host}";
|
||||
ensureUserModule = { config, ... }: {
|
||||
options = with lib.types; {
|
||||
authentication = {
|
||||
|
|
@ -46,7 +52,7 @@
|
|||
(mkIf config.authentication.local.allow (cidrForNetwork.loopback.all ++ cidrForNetwork.local.all))
|
||||
];
|
||||
authentication = mkMerge (map (host: ''
|
||||
host ${config.authentication.database} ${config.name} ${host} ${config.authentication.method}
|
||||
host ${config.authentication.database} ${config.name} ${formatHost host} ${config.authentication.method}
|
||||
'') config.authentication.hosts);
|
||||
};
|
||||
authentication.database = mkIf (config.ensureDBOwnership) (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue