forked from Drift/pvv-nixos-config
Compare commits
1 Commits
mediawiki-
...
setup-kerb
Author | SHA1 | Date | |
---|---|---|---|
fc1b7db291 |
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
../../base.nix
|
../../base.nix
|
||||||
../../misc/metrics-exporters.nix
|
../../misc/metrics-exporters.nix
|
||||||
|
../../modules/kerberos_auth.nix
|
||||||
|
|
||||||
#./services/keycloak.nix
|
#./services/keycloak.nix
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
./services/nginx.nix
|
./services/nginx.nix
|
||||||
./services/gitea/default.nix
|
./services/gitea/default.nix
|
||||||
./services/webmail
|
./services/webmail
|
||||||
./services/mediawiki.nix
|
# ./services/mediawiki.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
sops.defaultSopsFile = ../../secrets/bekkalokk/bekkalokk.yaml;
|
sops.defaultSopsFile = ../../secrets/bekkalokk/bekkalokk.yaml;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
{ pkgs, lib, config, values, pkgs-unstable, ... }: let
|
{ pkgs, lib, config, values, ... }: let
|
||||||
cfg = config.services.mediawiki;
|
cfg = config.services.mediawiki;
|
||||||
|
|
||||||
# "mediawiki"
|
# "mediawiki"
|
||||||
@@ -13,7 +13,7 @@ in {
|
|||||||
owner = user;
|
owner = user;
|
||||||
group = group;
|
group = group;
|
||||||
};
|
};
|
||||||
"mediawiki/database" = {
|
"keys/postgres/mediawiki" = {
|
||||||
restartUnits = [ "mediawiki-init.service" "phpfpm-mediawiki.service" ];
|
restartUnits = [ "mediawiki-init.service" "phpfpm-mediawiki.service" ];
|
||||||
owner = user;
|
owner = user;
|
||||||
group = group;
|
group = group;
|
||||||
@@ -30,7 +30,7 @@ in {
|
|||||||
type = "postgres";
|
type = "postgres";
|
||||||
host = "postgres.pvv.ntnu.no";
|
host = "postgres.pvv.ntnu.no";
|
||||||
port = config.services.postgresql.port;
|
port = config.services.postgresql.port;
|
||||||
passwordFile = config.sops.secrets."mediawiki/database".path;
|
passwordFile = config.sops.secrets."keys/postgres/mediawiki".path;
|
||||||
createLocally = false;
|
createLocally = false;
|
||||||
# TODO: create a normal database and copy over old data when the service is production ready
|
# TODO: create a normal database and copy over old data when the service is production ready
|
||||||
name = "mediawiki_test";
|
name = "mediawiki_test";
|
||||||
@@ -61,45 +61,35 @@ in {
|
|||||||
|
|
||||||
extensions = {
|
extensions = {
|
||||||
DeleteBatch = pkgs.fetchzip {
|
DeleteBatch = pkgs.fetchzip {
|
||||||
name = "mediawiki-delete-batch-source";
|
url = "https://extdist.wmflabs.org/dist/extensions/DeleteBatch-REL1_39-995ea6f.tar.gz";
|
||||||
url = "https://extdist.wmflabs.org/dist/extensions/DeleteBatch-REL1_40-4fe36dc.tar.gz";
|
sha256 = "sha256-0F4GLCy2f5WcWIY2YgF1tVxgYbglR0VOsj/pMrW93b8=";
|
||||||
hash = "sha256-jmRkjHFQR9cjPr1eBHVDLHm0xO4OPn9HYiYwrkBT/aA=";
|
|
||||||
};
|
};
|
||||||
UserMerge = pkgs.fetchzip {
|
UserMerge = pkgs.fetchzip {
|
||||||
name = "mediawiki-user-merge-source";
|
url = "https://extdist.wmflabs.org/dist/extensions/UserMerge-REL1_39-b10d50e.tar.gz";
|
||||||
url = "https://extdist.wmflabs.org/dist/extensions/UserMerge-REL1_40-7407806.tar.gz";
|
sha256 = "sha256-bXhj1+OlOUJDbvEuc8iwqb1LLEu6cN6+C/7cAvnWPOQ=";
|
||||||
hash = "sha256-NHAw79pDxjia46J5DIGV9AoF9UazSahT8DZgUUn/pQE=";
|
|
||||||
};
|
};
|
||||||
PluggableAuth = pkgs.fetchzip {
|
PluggableAuth = pkgs.fetchzip {
|
||||||
name = "mediawiki-pluggable-auth-source";
|
url = "https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_39-1210fc3.tar.gz";
|
||||||
url = "https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_40-eb10a76.tar.gz";
|
sha256 = "sha256-F6bTMCzkK3kZwZGIsNE87WlZWqXXmTMhEjApO99YKR0=";
|
||||||
hash = "sha256-GFmtQc0SeBpvI+7iHOVw77JR2h+hwPxo8+wZ9RED8a8=";
|
|
||||||
};
|
};
|
||||||
SimpleSAMLphp = pkgs.fetchzip {
|
SimpleSAMLphp = pkgs.fetchzip {
|
||||||
name = "mediawiki-simple-saml-php-source";
|
url = "https://extdist.wmflabs.org/dist/extensions/SimpleSAMLphp-REL1_39-dcf0acb.tar.gz";
|
||||||
url = "https://extdist.wmflabs.org/dist/extensions/SimpleSAMLphp-REL1_40-8043943.tar.gz";
|
sha256 = "sha256-tCvFmb2+q2rxms+lRo5pgoI3h6GjCwXAR8XisPg03TQ=";
|
||||||
hash = "sha256-HJHcrv/FNqPJegrHo4VPVjw0alkyHwetFZiLwjHsf6Y=";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = let
|
extraConfig = let
|
||||||
SimpleSAMLphpRepo = pkgs-unstable.php.buildComposerProject rec {
|
|
||||||
|
SimpleSAMLphpRepo = pkgs.stdenvNoCC.mkDerivation rec {
|
||||||
pname = "configuredSimpleSAML";
|
pname = "configuredSimpleSAML";
|
||||||
version = "2.1.0-rc1";
|
version = "2.0.4";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchzip {
|
||||||
owner = "simplesamlphp";
|
url = "https://github.com/simplesamlphp/simplesamlphp/releases/download/v${version}/simplesamlphp-${version}.tar.gz";
|
||||||
repo = "simplesamlphp";
|
sha256 = "sha256-pfMV/VmqqxgtG7Nx4s8MW4tWSaxOkVPtCRJwxV6RDSE=";
|
||||||
# name = "simple-saml-php-source";
|
|
||||||
# url = "https://github.com/simplesamlphp/simplesamlphp/releases/download/v${version}/simplesamlphp-${version}.tar.gz";
|
|
||||||
rev = "v${version}";
|
|
||||||
hash = "sha256-E7S6T/EfuhNbe697OiklZ77wMRkOb/ABJXoL5MphMCY=";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
composerStrictValidation = false;
|
buildPhase = ''
|
||||||
|
cat > config/authsources.php << EOF
|
||||||
vendorHash = "sha256-vr9mWXN9v6tGNvPtxQ+pgf7OYj8dedzWfxt6Xw1nCm0=";
|
|
||||||
|
|
||||||
configAuthsourcesPhp = ''
|
|
||||||
<?php
|
<?php
|
||||||
$config = array(
|
$config = array(
|
||||||
'default-sp' => array(
|
'default-sp' => array(
|
||||||
@@ -107,51 +97,11 @@ in {
|
|||||||
'idp' => 'https://idp.pvv.ntnu.no/',
|
'idp' => 'https://idp.pvv.ntnu.no/',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
'';
|
EOF
|
||||||
|
'';
|
||||||
|
|
||||||
# TODO: this could be fetched automagically with these:
|
installPhase = ''
|
||||||
# - https://simplesamlphp.org/docs/contrib_modules/metarefresh/simplesamlphp-automated_metadata.html
|
cp -r . $out
|
||||||
# - https://idp.pvv.ntnu.no/simplesaml/saml2/idp/metadata.php
|
|
||||||
metadataSaml20IdpRemotePhp = ''
|
|
||||||
<?php
|
|
||||||
$metadata['https://idp.pvv.ntnu.no/'] = array (
|
|
||||||
'metadata-set' => 'saml20-idp-remote',
|
|
||||||
'entityid' => 'https://idp.pvv.ntnu.no/',
|
|
||||||
'SingleSignOnService' =>
|
|
||||||
array (
|
|
||||||
0 =>
|
|
||||||
array (
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
||||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'SingleLogoutService' =>
|
|
||||||
array (
|
|
||||||
0 =>
|
|
||||||
array (
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
||||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'certData' => 'pvvcert.pem',
|
|
||||||
'NameIDFormat' =>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mj9tLDWoPsqet1QgyTTmQTgUmPhhMOQDqSh90LuqEJseKWafXGS/SfWLH6MWVmzDV5YofJEw2ThPiU58GiS06OLS2poq1eAesa2LQ22J8yYisXM4sxImIFte+LYQ1+1evfBWcvU1vrGsQ0VLJHdef9WoXp1swUFhq4Zk0c7gjHiB1CFVlExAAlk9L6W3CVXmKIYlf4eUnEBGkC061Ir42+uhAMWO9Y/L1NEuboTyd2KAI/6JdKdzpmfk7zPVxWlNxNCZ7OPNuvOKp6VlpB2EA==
|
|
||||||
'';
|
|
||||||
|
|
||||||
passAsFile = [
|
|
||||||
"configAuthsourcesPhp"
|
|
||||||
"metadataSaml20IdpRemotePhp"
|
|
||||||
"pvvcert"
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
install -Dm444 "$configAuthsourcesPhpPath" "config/authsources.php"
|
|
||||||
install -Dm444 "$metadataSaml20IdpRemotePhpPath" "metadata/saml20-idp-remote.php"
|
|
||||||
install -Dm444 "$pvvcertPath" "cert/pvvcert.pem"
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -222,23 +172,4 @@ in {
|
|||||||
|
|
||||||
${pkgs.php}/bin/php ${pkg}/share/mediawiki/maintenance/update.php --conf ${mediawikiConfig} --quick
|
${pkgs.php}/bin/php ${pkg}/share/mediawiki/maintenance/update.php --conf ${mediawikiConfig} --quick
|
||||||
'';
|
'';
|
||||||
|
|
||||||
services.nginx.virtualHosts."bekkalokk.pvv.ntnu.no" = {
|
|
||||||
forceSSL = true;
|
|
||||||
enableACME = true;
|
|
||||||
root = "${config.services.mediawiki.finalPackage}/share/mediawiki";
|
|
||||||
locations = {
|
|
||||||
"/" = {
|
|
||||||
extraConfig = ''
|
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
fastcgi_pass unix:${config.services.phpfpm.pools.mediawiki.socket};
|
|
||||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
|
||||||
include ${pkgs.nginx}/conf/fastcgi.conf;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
"/images".root = config.services.mediawiki.uploadsDir;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
25
modules/kerberos_auth.nix
Normal file
25
modules/kerberos_auth.nix
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{ pkgs, lib, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
heimdal
|
||||||
|
];
|
||||||
|
|
||||||
|
security.pam.krb5.enable = true;
|
||||||
|
|
||||||
|
environment.etc."krb5.conf".text = ''
|
||||||
|
[libdefaults]
|
||||||
|
default_realm = PVV.NTNU.NO
|
||||||
|
dns_lookup_realm = yes
|
||||||
|
dns_lookup_kdc = yes
|
||||||
|
|
||||||
|
[appdefaults]
|
||||||
|
pam = {
|
||||||
|
ignore_k5login = yes
|
||||||
|
}
|
||||||
|
|
||||||
|
[realms]
|
||||||
|
PVV.NTNU.NO = {
|
||||||
|
admin_server = kdc.pvv.ntnu.no
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
Reference in New Issue
Block a user