You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chris Toledo <Ch...@webcollage.com> on 2006/05/16 20:20:25 UTC

[users@httpd] LocationMatch - Match Site to AuthUserFile

I posted this early yesterday but I fear I haven't gotten a response due
to my unclear explanation, sorry if I am being a pain......

 

Setup: Apache 1.3.34 on Win32

 

We have a basic authentication setup that requires separate set of users
to log in to separate sites. As you can see from the setup below we are
separating authentication by site. This can be tedious as we create and
remove sites quite frequently. We want to implement one authorization
line that will match site to AuthUserFile. We want to avoid having to
add Authentication directive for every site created going forward. Is
there a way to use something like regular expressions and LocationMatch
to have Apache automatically match the site to the authentication file?
IE: User logs to site 2, Apache automatically routes to authentication
file ... "c:\data\configurations\users2.txt". I have tried doing the
following with no success...

 

<LocationMatch "/live/.*/">

      AuthType Basic

      AuthName "Enter Password:"

      AuthUserFile c:\data\configurations\$1\users.txt

 

 

Thank you in advance.

.......................

 

  Alias "/site1" "c:/data/live/site1"

  <Location "/site1">

      AuthType Basic

      AuthName "Enter Password:"

      AuthUserFile c:\data\configurations\site1\users.txt

      Require valid-user

  </Location>

 

  Alias "/site2" "c:/data/live/site2"

  <Location "/site2">

      AuthType Basic

      AuthName "Enter Password:"

      AuthUserFile c:\data\configurations\site2\users.txt

      Require valid-user

  </Location>

 

  Alias "/site3" "c:/data/live/site3"

  <Location "/site3">

      AuthType Basic

      AuthName "Enter Password:"

      AuthUserFile c:\data\configurations\site3\users.txt

      Require valid-user

  </Location>

 

 

 

 

Christian Toledo


Re: [users@httpd] LocationMatch - Match Site to AuthUserFile

Posted by Joshua Slive <jo...@slive.ca>.
On 5/16/06, Chris Toledo <Ch...@webcollage.com> wrote:

> We have a basic authentication setup that requires separate set of users to
> log in to separate sites. As you can see from the setup below we are
> separating authentication by site. This can be tedious as we create and
> remove sites quite frequently. We want to implement one authorization line
> that will match site to AuthUserFile. We want to avoid having to add
> Authentication directive for every site created going forward. Is there a
> way to use something like regular expressions and LocationMatch to have
> Apache automatically match the site to the authentication file? IE: User
> logs to site 2, Apache automatically routes to authentication file ...
> "c:\data\configurations\users2.txt". I have tried doing the
> following with no success…

No, there is no straight-forward way to do this.  I suggest simply
automating the maintenance of your config file using some tool that
can easily generate the required configuration changes.

An alternative is to have one password file that applies to all the
sites and then use mod_rewrite to check a dbm or txt database file to
see if the authenticated user is in the right "group" for the
directory.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org