Multiple Usernames/Passwords
If you want to give access to a directory to more than one
username/password pair, follow the same steps as for a single
username/password with the following additions:
Add additional users to the directory's
.htpasswd file.
Use the htpasswd command without the -c flag
to add additional users; e.g.:
htpasswd /otherdir/.htpasswd peanuts
htpasswd /otherdir/.htpasswd almonds
htpasswd /otherdir/.htpasswd walnuts
Create a group file.
Call it /otherdir/.htgroup and have it look something
like this:
my-users: pumpkin peanuts almonds walnuts
... where pumpkin, peanuts,
almonds, and walnuts are the usernames.
Then modify the .htaccess
file in the directory to look like this:
AuthUserFile /otherdir/.htpasswd
AuthGroupFile /otherdir/.htgroup
AuthName ByPassword
AuthType Basic
<Limit GET>
require group my-users
</Limit>
Note that AuthGroupFile now points to your group file and
that group my-users (rather than individual user
pumpkin) is now required for access.
That's it. Now any user in group my-users can use
his/her individual username and password to gain access to directory
turkey.
Prepared Examples
Following are several examples of the range of access authorization
capabilities available through Mosaic and NCSA HTTPd. The examples
are served from a system at NCSA.
- Simple protection by password.
- This document
is accessible only to user
fido with password
bones.
Important Note: There is no correspondence between
usernames and passwords on specific Unix systems (e.g. in an
/etc/passwd file) and usernames and passwords in the
authentication schemes we're discussing for use in the Web. As
illustrated in the examples, Web-based authentication uses
similar but wholly distinct password files; a user need
never have an actual account on a given Unix system in order to
be validated for access to files being served from that system
and protected with HTTP-based authentication.
- Protection by password; multiple users allowed.
- This
document is accessible to user
rover with
password bacon and user jumpy with
password kibbles.
- Protection by network domain.
- This document is
only accessible to clients running on machines inside domain
ncsa.uiuc.edu.
Note for non-NCSA readers: The .htaccess file
used in this case is as follows:
AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName ExampleAllowFromICN
AuthType Basic
<Limit GET>
order deny,allow
deny from all
allow from .niagara.com
</Limit>
- Protection by network domain -- exclusion.
- This
document is accessible to clients running on machines
anywhere but inside domain
ncsa.uiuc.edu.
Note for readers: The .htaccess file
used in this case is as follows:
AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName ExampleDenyFromNCSA
AuthType Basic
<Limit GET>
order allow,deny
allow from all
deny from .ncsa.uiuc.edu
</Limit>