]>
Commit | Line | Data |
---|---|---|
da30ae4f | 1 | { stdenv, fetchurl, gettext, writeText, env, awl, davical, config }: |
452c2314 | 2 | rec { |
4288c2f2 IB |
3 | activationScript = { |
4 | deps = [ "httpd" ]; | |
5 | text = '' | |
6 | install -m 0755 -o ${apache.user} -g ${apache.group} -d /var/lib/php/sessions/davical | |
7 | ''; | |
8 | }; | |
4c4652aa | 9 | keys."webapps/dav-davical" = { |
452c2314 IB |
10 | user = apache.user; |
11 | group = apache.group; | |
12 | permissions = "0400"; | |
13 | text = '' | |
14 | <?php | |
15 | $c->pg_connect[] = "dbname=${env.postgresql.database} user=${env.postgresql.user} host=${env.postgresql.socket} password=${env.postgresql.password}"; | |
d9998b44 | 16 | |
452c2314 | 17 | $c->readonly_webdav_collections = false; |
d9998b44 | 18 | |
452c2314 | 19 | $c->admin_email ='davical@tools.immae.eu'; |
d9998b44 | 20 | |
452c2314 | 21 | $c->restrict_setup_to_admin = true; |
d9998b44 | 22 | |
452c2314 | 23 | $c->collections_always_exist = false; |
d9998b44 | 24 | |
452c2314 | 25 | $c->external_refresh = 60; |
d9998b44 | 26 | |
452c2314 | 27 | $c->enable_scheduling = true; |
d9998b44 | 28 | |
452c2314 | 29 | $c->iMIP = (object) array("send_email" => true); |
d9998b44 | 30 | |
452c2314 IB |
31 | $c->authenticate_hook['optional'] = false; |
32 | $c->authenticate_hook['call'] = 'LDAP_check'; | |
33 | $c->authenticate_hook['config'] = array( | |
ab8f306d | 34 | 'host' => '${env.ldap.host}', |
452c2314 IB |
35 | 'port' => '389', |
36 | 'startTLS' => 'yes', | |
ab8f306d | 37 | 'bindDN'=> '${env.ldap.dn}', |
452c2314 IB |
38 | 'passDN'=> '${env.ldap.password}', |
39 | 'protocolVersion' => '3', | |
ab8f306d IB |
40 | 'baseDNUsers'=> array('ou=users,${env.ldap.base}', 'ou=group_users,${env.ldap.base}'), |
41 | 'filterUsers' => '${env.ldap.filter}', | |
42 | 'baseDNGroups' => 'ou=groups,${env.ldap.base}', | |
43 | 'filterGroups' => 'memberOf=cn=groups,${env.ldap.dn}', | |
452c2314 IB |
44 | 'mapping_field' => array( |
45 | "username" => "uid", | |
46 | "fullname" => "cn", | |
47 | "email" => "mail", | |
48 | "modified" => "modifyTimestamp", | |
49 | ), | |
50 | 'format_updated'=> array('Y' => array(0,4),'m' => array(4,2),'d'=> array(6,2),'H' => array(8,2),'M'=>array(10,2),'S' => array(12,2)), | |
51 | /** used to set default value for all users, will be overcharged by ldap if defined also in mapping_field **/ | |
52 | // 'default_value' => array("date_format_type" => "E","locale" => "fr_FR"), | |
53 | 'group_mapping_field' => array( | |
54 | "username" => "cn", | |
55 | "updated" => "modifyTimestamp", | |
56 | "fullname" => "givenName", | |
57 | "displayname" => "givenName", | |
58 | "members" => "memberUid", | |
59 | "email" => "mail", | |
60 | ), | |
61 | ); | |
d9998b44 | 62 | |
452c2314 IB |
63 | $c->do_not_sync_from_ldap = array('admin' => true); |
64 | include('drivers_ldap.php'); | |
65 | ''; | |
4c4652aa | 66 | }; |
da30ae4f | 67 | webapp = davical.override { davical_config = config.secrets.fullPaths."webapps/dav-davical"; }; |
452c2314 IB |
68 | webRoot = "${webapp}/htdocs"; |
69 | apache = rec { | |
70 | user = "wwwrun"; | |
71 | group = "wwwrun"; | |
72 | modules = [ "proxy_fcgi" ]; | |
73 | webappName = "tools_davical"; | |
74 | root = "/run/current-system/webapps/${webappName}"; | |
5400b9b6 | 75 | vhostConf = socket: '' |
452c2314 IB |
76 | Alias /davical "${root}" |
77 | Alias /caldav.php "${root}/caldav.php" | |
78 | <Directory "${root}"> | |
79 | DirectoryIndex index.php index.html | |
80 | AcceptPathInfo On | |
81 | AllowOverride None | |
82 | Require all granted | |
d9998b44 | 83 | |
452c2314 IB |
84 | <FilesMatch "\.php$"> |
85 | CGIPassAuth on | |
5400b9b6 | 86 | SetHandler "proxy:unix:${socket}|fcgi://localhost" |
452c2314 | 87 | </FilesMatch> |
d9998b44 | 88 | |
452c2314 IB |
89 | RewriteEngine On |
90 | <IfModule mod_headers.c> | |
91 | Header unset Access-Control-Allow-Origin | |
92 | Header unset Access-Control-Allow-Methods | |
93 | Header unset Access-Control-Allow-Headers | |
94 | Header unset Access-Control-Allow-Credentials | |
95 | Header unset Access-Control-Expose-Headers | |
d9998b44 | 96 | |
452c2314 IB |
97 | Header always set Access-Control-Allow-Origin "*" |
98 | Header always set Access-Control-Allow-Methods "GET,POST,OPTIONS,PROPFIND,PROPPATCH,REPORT,PUT,MOVE,DELETE,LOCK,UNLOCK" | |
99 | Header always set Access-Control-Allow-Headers "User-Agent,Authorization,Content-type,Depth,If-match,If-None-Match,Lock-Token,Timeout,Destination,Overwrite,Prefer,X-client,X-Requested-With" | |
100 | Header always set Access-Control-Allow-Credentials false | |
101 | Header always set Access-Control-Expose-Headers "Etag,Preference-Applied" | |
d9998b44 | 102 | |
452c2314 IB |
103 | RewriteCond %{HTTP:Access-Control-Request-Method} !^$ |
104 | RewriteCond %{REQUEST_METHOD} OPTIONS | |
105 | RewriteRule ^(.*)$ $1 [R=200,L] | |
106 | </IfModule> | |
107 | </Directory> | |
108 | ''; | |
109 | }; | |
110 | phpFpm = rec { | |
111 | serviceDeps = [ "postgresql.service" "openldap.service" ]; | |
da30ae4f | 112 | basedir = builtins.concatStringsSep ":" [ webapp config.secrets.fullPaths."webapps/dav-davical" awl ]; |
5400b9b6 IB |
113 | pool = { |
114 | "listen.owner" = apache.user; | |
115 | "listen.group" = apache.group; | |
116 | "pm" = "dynamic"; | |
117 | "pm.max_children" = "60"; | |
118 | "pm.start_servers" = "2"; | |
119 | "pm.min_spare_servers" = "1"; | |
120 | "pm.max_spare_servers" = "10"; | |
d9998b44 | 121 | |
5400b9b6 IB |
122 | # Needed to avoid clashes in browser cookies (same domain) |
123 | "php_value[session.name]" = "DavicalPHPSESSID"; | |
124 | "php_admin_value[open_basedir]" = "${basedir}:/tmp:/var/lib/php/sessions/davical"; | |
125 | "php_admin_value[include_path]" = "${awl}/inc:${webapp}/inc"; | |
126 | "php_admin_value[session.save_path]" = "/var/lib/php/sessions/davical"; | |
127 | "php_flag[magic_quotes_gpc]" = "Off"; | |
128 | "php_flag[register_globals]" = "Off"; | |
129 | "php_admin_value[error_reporting]" = "E_ALL & ~E_NOTICE"; | |
130 | "php_admin_value[default_charset]" = "utf-8"; | |
131 | "php_flag[magic_quotes_runtime]" = "Off"; | |
132 | }; | |
d9998b44 | 133 | }; |
452c2314 | 134 | } |