How to use more than one AuthUserFile per context

Apache 2.2 has a module called mod_authn_alias which can be used to query multiple authentication sources in a single context.

The scenario here is:

  • htpasswd has been used to create two separate password files
  • Any user in these files may access a given URL

There are other approaches to this problem like merging the separate files together, perhaps as part of the Apache init script. Otherwise one might use AuthGroupFile and list all users from both files. These are troublesome though as in the first case the Apache init script might be overwritten during an upgrade and the second case is just tedious.

<AuthnProviderAlias file file1>
  AuthUserFile conf/file1.passwd
</AuthnProviderAlias>
<AuthnProviderAlias file file2>
  AuthUserFile conf/file2.passwd
</AuthnProviderAlias>

<VirtualHost *:80>
  ServerName example.org
  DocumentRoot /var/www/example.org
  <Location />
    AuthBasicProvider file1 file2
    AuthName 'Area Restricted by mod_authn_alias'
    AuthType basic
    Require valid-user
  </Location>
</VirtualHost>
  • No labels