python: Fix build issues when using "make build_cached"
[omd.git] / packages / check_mk / MULTISITE_COOKIE_AUTH.hook
blobf59b2fde73bb9fa6a75e9fbdabcd1f83c7d06e92
1 #!/bin/bash
3 # Alias: Use multisite cookie auth
4 # Menu: Web GUI
5 # Description:
6 # Multisite provides a cookie based authentication which can be
7 # used as alternative to the default basic authentication.
8 # The cookie authentication is done by multisite. The cookie can
9 # also be used by other addons like NagVis. This is switched
10 # using this option.
12 case "$1" in
13 default)
14 echo "off"
16 choices)
17 echo "on: use cookie authentication"
18 echo "off: use basic authentication"
20 set)
21 APACHE_CFG=${OMD_ROOT}/etc/apache/conf.d/cookie_auth.conf
22 NAGVIS_CFG=${OMD_ROOT}/etc/nagvis/conf.d/cookie_auth.ini.php
23 PNP_CFG=${OMD_ROOT}/etc/pnp4nagios/config.d/cookie_auth.php
24 WIKI_CFG=${OMD_ROOT}/etc/dokuwiki/cookie_auth.php
25 if [ "$2" == "on" ]; then
26 cat > $APACHE_CFG <<EOF
27 <LocationMatch ^/${OMD_SITE}/(omd|wiki|nagvis|check_mk|pnp4nagios)>
28 Order allow,deny
29 Allow from all
30 Satisfy any
31 </LocationMatch>
32 EOF
34 if [ -d ${NAGVIS_CFG%/*} ]; then
35 cat > $NAGVIS_CFG <<EOF
36 [global]
37 logonmodule="LogonMultisite"
38 logon_multisite_htpasswd="/omd/sites/$OMD_SITE/etc/htpasswd"
39 logon_multisite_secret="/omd/sites/$OMD_SITE/etc/auth.secret"
40 logon_multisite_serials="/omd/sites/$OMD_SITE/etc/auth.serials"
41 EOF
44 if [ -d ${WIKI_CFG%/*} ]; then
45 cat > $WIKI_CFG <<EOF
46 <?php
47 // Created by OMD hook MULTISITE_COOKIE_AUTH
49 \$conf['useacl'] = 1;
50 \$conf['authtype'] = 'authmultisite';
51 \$conf['superuser'] = '@admin';
52 \$conf['multisite']['authfile'] = '/omd/sites/$OMD_SITE/var/check_mk/wato/auth/auth.php';
53 \$conf['multisite']['auth_secret'] = '/omd/sites/$OMD_SITE/etc/auth.secret';
54 \$conf['multisite']['auth_serials'] = '/omd/sites/$OMD_SITE/etc/auth.serials';
55 \$conf['multisite']['htpasswd'] = '/omd/sites/$OMD_SITE/etc/htpasswd';
57 EOF
60 if [ -d ${PNP_CFG%/*} ]; then
61 cat > $PNP_CFG <<EOF
62 <?php
63 // Created by OMD hook MULTISITE_COOKIE_AUTH
65 // Using the multisite cookie based authentication when no
66 // REMOTE_USER available.
68 \$conf['auth_multisite_enabled'] = TRUE;
69 \$conf['auth_multisite_htpasswd'] = '/omd/sites/$OMD_SITE/etc/htpasswd';
70 \$conf['auth_multisite_secret'] = '/omd/sites/$OMD_SITE/etc/auth.secret';
71 \$conf['auth_multisite_serials'] = '/omd/sites/$OMD_SITE/etc/auth.serials';
72 \$conf['auth_multisite_login_url'] = '/$OMD_SITE/check_mk/login.py';
74 EOF
77 else
78 [ -f $APACHE_CFG ] && rm $APACHE_CFG
79 [ -f $NAGVIS_CFG ] && rm $NAGVIS_CFG
80 [ -f $PNP_CFG ] && rm $PNP_CFG
81 [ -f $WIKI_CFG ] && rm $WIKI_CFG
83 true
85 esac