aa122cbae7
This CL can be used to compare the style of nixpkgs-fmt against other formatters (nixpkgs, alejandra). Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: cynthia <cynthia@tvl.fyi> Reviewed-by: edef <edef@edef.eu> Reviewed-by: eta <tvl@eta.st> Reviewed-by: grfn <grfn@gws.fyi>
53 lines
1.5 KiB
Nix
53 lines
1.5 KiB
Nix
# Configuration for oauth2_proxy, which is used as a handler for nginx
|
|
# auth-request setups.
|
|
#
|
|
# This module exports a helper function at
|
|
# `config.services.depot.oauth2_proxy.withAuth` that can be wrapped
|
|
# around nginx server configuration blocks to configure their
|
|
# authentication setup.
|
|
{ config, depot, pkgs, lib, ... }:
|
|
|
|
let
|
|
description = "OAuth2 proxy to authenticate TVL services";
|
|
cfg = config.services.depot.oauth2_proxy;
|
|
configFile = pkgs.writeText "oauth2_proxy.cfg" ''
|
|
email_domains = [ "*" ]
|
|
http_address = "127.0.0.1:${toString cfg.port}"
|
|
provider = "keycloak-oidc"
|
|
client_id = "oauth2-proxy"
|
|
oidc_issuer_url = "https://auth.tvl.fyi/auth/realms/TVL"
|
|
reverse_proxy = true
|
|
set_xauthrequest = true
|
|
'';
|
|
in
|
|
{
|
|
options.services.depot.oauth2_proxy = {
|
|
enable = lib.mkEnableOption description;
|
|
|
|
port = lib.mkOption {
|
|
description = "Port to listen on";
|
|
type = lib.types.int;
|
|
default = 2884; # "auth"
|
|
};
|
|
|
|
secretsFile = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "EnvironmentFile from which to load secrets";
|
|
default = "/run/agenix/oauth2_proxy";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.oauth2_proxy = {
|
|
inherit description;
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
Restart = "always";
|
|
DynamicUser = true;
|
|
EnvironmentFile = cfg.secretsFile;
|
|
ExecStart = "${pkgs.oauth2_proxy}/bin/oauth2-proxy --config ${configFile}";
|
|
};
|
|
};
|
|
};
|
|
}
|