소스 검색

Add a separate HTTP authorization for PHP(My|Pg)Admin

Emmanuel Bouthenot 9 년 전
부모
커밋
fb2f6a3509

+ 7 - 4
roles/webserver/defaults/main.yml

@@ -24,7 +24,7 @@ fpm_max_spare_servers: 3
 with_php: False
 with_php_mysql_legacy: False
 
-phpsyscheck_vhostname: sys.localhost
+phpsyscheck_vhostname: 'sys.localhost'
 
 php_config:
   date.timezone: 'Europe/Paris'
@@ -42,12 +42,15 @@ php_config_web:
 with_php_apc: False
 
 with_phpmyadmin: False
-phpmyadmin_vhostname: pma.localhost
-http_auth_phpmyadmin_username: ''
-http_auth_phpmyadmin_password: ''
+phpmyadmin_vhostname: 'pma.localhost'
+http_auth_phpmyadmin: False
 
 with_phppgadmin: False
 phppgadmin_vhostname: 'pga.localhost'
 http_auth_phppgadmin: False
 
+http_auth_admin_password: Null
+http_auth_user_name: Null
+http_auth_user_password: Null
+
 # vim: ft=yaml

+ 3 - 1
roles/webserver/templates/apache2/auth_admin.j2

@@ -1,4 +1,6 @@
+{% if http_auth_admin_password %}
 admin:{{ http_auth_admin_password }}
-{% if http_auth_user_name != '' and http_auth_user_password != '' %}
+{% endif %}
+{% if http_auth_user_name and http_auth_user_password %}
 {{ http_auth_user_name }}:{{ http_auth_user_password }}
 {% endif %}

+ 2 - 0
roles/webserver/templates/apache2/pma_vhost.j2

@@ -10,12 +10,14 @@
     DocumentRoot /usr/share/phpmyadmin
     DirectoryIndex index.php
 
+{% if http_auth_phpmyadmin %}
     <Location />
         AuthType basic
         AuthName "Restricted Access"
         AuthUserFile /etc/apache2/auth_admin
         Require valid-user
     </Location>
+{% endif %}
 
     Include /etc/phpmyadmin/apache.conf
 

+ 3 - 1
roles/webserver/templates/nginx/auth_admin.j2

@@ -1,4 +1,6 @@
+{% if http_auth_admin_password %}
 admin:{{ http_auth_admin_password }}
-{% if http_auth_user_name != '' and http_auth_user_password != '' %}
+{% endif %}
+{% if http_auth_user_name and http_auth_user_password %}
 {{ http_auth_user_name }}:{{ http_auth_user_password }}
 {% endif %}

+ 2 - 1
roles/webserver/templates/nginx/pma_vhost.j2

@@ -14,8 +14,10 @@ server {
     index index.php;
     try_files $uri $uri/ /index.php;
 
+{% if http_auth_phpmyadmin %}
     auth_basic "Restricted Access";
     auth_basic_user_file /etc/nginx/auth_admin;
+{% endif %}
 
     client_max_body_size 32m;
 
@@ -23,4 +25,3 @@ server {
         include fastcgi_pass_fpm;
     }
 }
-