You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Patrick L. Nolan" <pl...@razzle.Stanford.EDU> on 2003/08/20 00:31:30 UTC

[users@httpd] Two levels of authentication

I'm trying to do something that I haven't seen in any of the 
examples or in anything I have found in Google.  This is with
Apache 2.0.40 on Linux.

We have a web site with a few hundred users who authorize
through mod_auth_mysql.  That's been running for years, through
many versions of Apache.  There's a small, elite group with
their own realm.  Recently I set that up with basic authorization.
The passwords in the elite realm are different from the ones in
the larger realm.  Now the elite users are annoyed that they have 
to re-authorize when they move out of their elite area to the
main area.

It seems reasonable that the main realm should be able to recognize 
both its own credentials and the ones issued in the elite realm.  
I set up something like this:

<Directory /home/www/htdocs/elite>
Options Indexes FollowSymLinks
AuthName "Private area for elite users"
AuthType Basic
AuthUserFile /home/www/htdocs/elite/htpasswd
AuthGroupFile /home/www/htdocs/elite/htgroups
order deny,allow
require group elite
</Directory>

<Directory /home/www/htdocs/ordinary>
Options Indexes FollowSymLinks
AuthName "The area for the ordinary folks"
AuthMySQLHost localhost
AuthMySQLUser userid
AuthMySQLPassword password
AuthMySQLDB database
AuthMySQLUserTable table
AuthMySQLGroupField groups
AuthMySQLNameField userid
AuthMySQLPasswordField passwd
AuthMySQLCryptedPasswords on
AuthMySQLAuthoritative off
AuthMySQLKeepAlive on
order deny,allow
deny from all
require group ordinary

AuthType basic
AuthUserFile /home/www/htdocs/elite/htpasswd
AuthGroupFile /home/www/htdocs/elite/htgroups
require group elite
satisfy any
</Directory>

The first set of lines, for the elite area, is quite orthodox.
It works OK.  In the second set, for the ordinary area, the
MySQL part works well.  I added the stuff at the end, basically
copying the elite setup and adding "satisfy any".  I thought it
would do the job.  It doesn't seem to do anything.

Apparently I don't understand these things well enough.  An elite 
user can log into either area with the appropriate password.
However, when passing from one to the other, it is necessary to
re-authenticate.  In particular, when going to the ordinary area,
it doesn't seem to remember that "require group elite" is already
satisfied.

Is there some way to do this?

*   Patrick L. Nolan                                          *
*   W. W. Hansen Experimental Physics Laboratory (HEPL)       * 
*   Stanford University                                       *


---------------------------------------------------------------------
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


Re: [users@httpd] Two levels of authentication

Posted by Robert Andersson <ro...@profundis.nu>.
Patrick L. Nolan wrote:
> <Directory /home/www/htdocs/elite>
> AuthName "Private area for elite users"
> </Directory>
>
> <Directory /home/www/htdocs/ordinary>
> AuthName "The area for the ordinary folks"
> </Directory>

You see, it isn't Apache that desides whether or not the user is prompted
for the credentials. As HTTP is a stateless protocol with no concept of
sessions, the User-Agent is required to send the credentials with each and
every request, so it could theoretically challenge the user each time a
resource is requested. However, it is supposed to recognize "authentication
realms" together with URL scope (eg. so that it doesn't send passwords to
another site) to recycle the credentials, and as your realms are named
differently the User-Agent MUST NOT send credentials for the other without
prompting the user. So, if your 'elite' area is located in a sub directory,
you might be able to achieve this by giving the realm the same name. If they
are on different hosts, you will not be able to do this without serious
client side hacks (eg. set location to 'http://login:pass@elitehost/' with
JavaScript).

However, unless I misunderstand something about your requirements, shouldn't
you be able to have all users in the same database but create an 'elite'
group that is allowed into the 'elite' area?

Regards,
Robert Andersson


---------------------------------------------------------------------
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