You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Richard Davies <ri...@daviesmail.org> on 2012/05/23 13:30:53 UTC

[users@httpd] Single auth file for many per-user directories

Hi all,

I would appreciate any suggetions on how to achieve the following:

I have a large number of per-user directories:

  /var/www/user1
  /var/www/user2
  /var/www/user3
  ...

And a htdigest file containing usernames and passwords for all of these
users.

I want to set up authentication for each user to access just their own
directory.

The obvious method is to have a very long Apache config file, with
"Require user1", "Require user2", etc. specified manually for each
directory.

However, I have a lot of users!

Is there some clever way around this, for example a way to do:

  Require <auth_username=root_directory_name>


Or alternatively, a way for me to have "Require valid-user", but then
somehow prevent users from accessing directories other than their own?
(even with a hack like rewrite rules?)

Thanks for any pointers,

Richard.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Single auth file for many per-user directories

Posted by Michael Streeter <ms...@gmail.com>.
On 05/23/2012 06:58 AM, Richard Davies wrote:
> Eric Covener wrote:
>>> ?Require<auth_username=root_directory_name>
>>>
>>> Or alternatively, a way for me to have "Require valid-user", but then
>>> somehow prevent users from accessing directories other than their own?
>>> (even with a hack like rewrite rules?)
>> There is a shortcut if the those names are system users and they
>> actually own their directories:
>>
>> http://httpd.apache.org/docs/2.2/mod/mod_authz_owner.html
> Unfortunately, they aren't - they're just entries in an htdigest file.
>
> Richard.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
You might be able to use mod-auth-external along with LocationMatch.  I 
haven't used mod-auth-external, but it looks like it could work:

<LocationMatch  "/var/www/.*">
     #mod-auth-external  <http://code.google.com/p/mod-auth-external/>  directives that call a custom script
</LocationMatch>

Then write a script that makes sure the username/password checks out and 
also makes sure the URI is within that user's directory.

http://code.google.com/p/mod-auth-external/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Single auth file for many per-user directories

Posted by Richard Davies <ri...@daviesmail.org>.
Eric Covener wrote:
> > ?Require <auth_username=root_directory_name>
> >
> > Or alternatively, a way for me to have "Require valid-user", but then
> > somehow prevent users from accessing directories other than their own?
> > (even with a hack like rewrite rules?)
>
> There is a shortcut if the those names are system users and they
> actually own their directories:
>
> http://httpd.apache.org/docs/2.2/mod/mod_authz_owner.html

Unfortunately, they aren't - they're just entries in an htdigest file.

Richard.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Single auth file for many per-user directories

Posted by Eric Covener <co...@gmail.com>.
>  Require <auth_username=root_directory_name>
>
> Or alternatively, a way for me to have "Require valid-user", but then
> somehow prevent users from accessing directories other than their own?
> (even with a hack like rewrite rules?)


There is a shortcut if the those names are system users and they
actually own their directories:

http://httpd.apache.org/docs/2.2/mod/mod_authz_owner.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org