I'm trying to set up an authentication system based on basic apache2 auth. For this I configured mod_authn_dbd to use a mysqli database set up like this: https://www.howtoforge.de/anleitung/passwort-geschutzte-verzeichnisse-auf-apache2-mit-mod_auth_mysql-debian-squeeze/.
Next, I set up my site.conf like this:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName exmpl.de
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
DBDriver mysql
DBDParams "dbname=db user=usr pass=pass"
DBDMin 4
DBDKeep 8
DBDMax 20
DBDExptime 300
<Directory "/var/www/html">
# mod_authn_core and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
AuthName "Users only"
# To cache credentials, put socache ahead of dbd here
AuthBasicProvider socache dbd
# Also required for caching: tell the cache to cache dbd lookups!
AuthnCacheProvideFor dbd
AuthnCacheContext my-server
# mod_authz_core configuration
Require valid-user
# mod_authn_dbd SQL query to authenticate a user
AuthDBDUserPWQuery "SELECT passwd FROM mysql_auth WHERE username = %s"
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
which works like a charm with my database:
create table mysql_auth (
username varchar(255) not null,
passwd varchar(255),
groups varchar(255),
primary key (username)
);
Now I wanted to add the possibility to make specific folders and its content only available for users of a specific group, so I added:
<Directory "/var/www/html/folder1/folder2">
# mod_authn_core and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
AuthName group specific area
AuthBasicProvider dbd
# mod_authn_dbd SQL query to authenticate a logged-in user
AuthDBDUserPWQuery \
"SELECT password FROM mysql_auth WHERE username = %s"
# mod_authz_core configuration for mod_authz_dbd
Require dbd-group groupname
# mod_authz_dbd configuration
AuthzDBDQuery "SELECT groups FROM mysql_auth WHERE user = %s"
</Directory>
(https://httpd.apache.org/docs/current/mod/mod_authz_dbd.html)with the result that I get this message after reenabling the site.conf and trying to restart apache2:
Mar 23 23:31:12 v*** apachectl[1665]: AH00526: Syntax error on line 70 of /etc/apache2/sites-enabled/site.conf:
Mar 23 23:31:12 v*** apachectl[1665]: Unknown Authz provider: dbd-group
Even "Require group groupname" doesn't work. I really don't know what I'mm doing wrong. Any ideas?
Thanks in advance.