From dbd125b0557fe5c1be10c2a08a09fcf4054b0d74 Mon Sep 17 00:00:00 2001 From: Paul Wilson Date: Thu, 10 Sep 2015 14:49:09 +0000 Subject: [PATCH 1/2] gitit service: add github authentication --- nixos/modules/services/misc/gitit.nix | 47 +++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/misc/gitit.nix b/nixos/modules/services/misc/gitit.nix index 10a706fbd71d..d5ad4faa6fe6 100644 --- a/nixos/modules/services/misc/gitit.nix +++ b/nixos/modules/services/misc/gitit.nix @@ -99,7 +99,7 @@ let }; authenticationMethod = mkOption { - type = types.enum [ "form" "http" "generic"]; + type = types.enum [ "form" "http" "generic" "github" ]; default = "form"; description = '' 'form' means that users will be logged in and registered using forms @@ -537,6 +537,42 @@ video/x-ms-wmx wmx through xss-sanitize. Set to no only if you trust all of your users. ''; }; + + oauthClientId = mkOption { + type = with types; nullOr str; + default = null; + description = "OAuth client ID"; + }; + + oauthClientSecret = mkOption { + type = with types; nullOr str; + default = null; + description = "OAuth client secret"; + }; + + oauthCallback = mkOption { + type = with types; nullOr str; + default = null; + description = "OAuth callback URL"; + }; + + oauthAuthorizeEndpoint = mkOption { + type = with types; nullOr str; + default = null; + description = "OAuth authorize endpoint"; + }; + + oauthAccessTokenEndpoint = mkOption { + type = with types; nullOr str; + default = null; + description = "OAuth access token endpoint"; + }; + + githubOrg = mkOption { + type = with types; nullOr str; + default = null; + description = "Github organization"; + }; }; configFile = pkgs.writeText "gitit.conf" '' @@ -587,6 +623,14 @@ video/x-ms-wmx wmx pdf-export: ${toYesNo cfg.pdfExport} pandoc-user-data: ${toString cfg.pandocUserData} xss-sanitize: ${toYesNo cfg.xssSanitize} + + [Github] + oauthclientid: ${cfg.oauthClientId} + oauthclientsecret: ${cfg.oauthClientSecret} + oauthcallback: ${cfg.oauthCallback} + oauthauthorizeendpoint: ${cfg.oauthAuthorizeEndpoint} + oauthaccesstokenendpoint: ${cfg.oauthAccessTokenEndpoint} + github-org: ${cfg.githubOrg} ''; in @@ -681,4 +725,3 @@ NAMED }; }; } - From d2ca8b4079a2c5c31e519d70b797971825ebd2b1 Mon Sep 17 00:00:00 2001 From: Paul Wilson Date: Thu, 10 Sep 2015 17:23:31 +0000 Subject: [PATCH 2/2] gitit service: check null github auth options --- nixos/modules/services/misc/gitit.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/misc/gitit.nix b/nixos/modules/services/misc/gitit.nix index d5ad4faa6fe6..8e9e761b6092 100644 --- a/nixos/modules/services/misc/gitit.nix +++ b/nixos/modules/services/misc/gitit.nix @@ -625,12 +625,12 @@ video/x-ms-wmx wmx xss-sanitize: ${toYesNo cfg.xssSanitize} [Github] - oauthclientid: ${cfg.oauthClientId} - oauthclientsecret: ${cfg.oauthClientSecret} - oauthcallback: ${cfg.oauthCallback} - oauthauthorizeendpoint: ${cfg.oauthAuthorizeEndpoint} - oauthaccesstokenendpoint: ${cfg.oauthAccessTokenEndpoint} - github-org: ${cfg.githubOrg} + oauthclientid: ${toString cfg.oauthClientId} + oauthclientsecret: ${toString cfg.oauthClientSecret} + oauthcallback: ${toString cfg.oauthCallback} + oauthauthorizeendpoint: ${toString cfg.oauthAuthorizeEndpoint} + oauthaccesstokenendpoint: ${toString cfg.oauthAccessTokenEndpoint} + github-org: ${toString cfg.githubOrg} ''; in