
The ECN No Name Newsletter is no longer being published. This is an archived issue.
[previous article]Cathy Curry
You can control access to your web documents using Domain Access Control, User Authentication or a combination of both. Domain Access Control is based on the acceptance or rejection of a connection based on the client's Internet address or host or domain name. User Authentication is based on the entry of a username and password.
Both of these methods use a file named .htaccess to control access to the restricted directory. You can have both Domain Access Control and User Authentication defined in the same .htaccess file.
The server ALWAYS processes ALL of the lines. You control whether it does allow before deny, or deny before allow. The results are not always the same:
<Limit GET> order deny,allow allow from all deny from all <Limit>
<Limit GET> order allow,deny allow from all deny from all <Limit>
Example 1: To exclude one group:
order allow,deny allow from all deny from group (domain name)
<Limit GET> order allow,deny allow from all deny from ecn.purdue.edu <Limit>
Result: EVERYONE except ECN hosts are allowed into ~/public-web.
Example 2: To allow one group:
order deny,allow deny from all allow from group (domain name)
<Limit GET> order deny,allow deny from all allow from ecn.purdue.edu <Limit>
Result: only ECN hosts are allowed into ~/public-web.
To specify multiple organizations (i.e., ecn domain, cs domain and a non-profit organization) you separate with a whitespace, no commas:
allow ecn.purdue.edu cs.purdue.edu non.profit.org
Files used for User Authentication:
File Description Naming
.htaccess the file to control access .htaccess
.htpasswd the hypertext password file any name
.htgroup the file which defines any name
the users in a specific group
The .htaccess file will be comprised of the following directives:
<Limit GET> require <Limit>
The require directive tells httpd to prompt for a username and password, and it is only allowed within the Limit section.
User Authentication does not read the system's /etc/passswd file. Web-based authentication uses similar but distinct password files; a user does not need to have an actual account on the given Unix system for access to these protected files.
When user authentication is in place, the user is given two prompts (username and password) to which he must respond correctly before access is allowed. Once the user is authenticated, he can navigate from page to page without repeated authentication prompts.
The following four Auth directives go outside the Limit sectioning directive. All four directives must be defined for user authentication to work properly.
For our example, we will authenticate ~/public-web, so only user "jruser" with password "gopurdue" can access this.
cd ~
mkdir auth\fR
In the HOME directory, a directory named auth will contain the password file.
cd ~/public-web
AuthUserFile /home/harbor/a/your-login/auth/.htpasswd AuthGroupFile /dev/null Authname ByPassword AuthType Basic
<Limit GET>
require group my-users
<Limit>
/usr/local/etc/httpd/support/htpasswd -c ~/auth/.htpasswd jruser
The htpasswd program is stored in /usr/local/etc/httpd/support/. You must use the -c flag when you FIRST create a password file. ~/auth/.htpasswd is the location of your personal password file. In your .htaccess file, "jruser" is the username you specified.
ls -al
in your auth directory to list it.
my-users: jruser lois ned lila
cd ~/public-web
AuthUserFile /home/server/a/your-login/auth/.htpasswd AuthGroupFile /home/harbor/a/your-login/auth/.htgroup Authname ByPassword AuthType Basic
<Limit GET>
require group my-users
<Limit>
/usr/local/etc/httpd/support/htpasswd ~/auth/.htpasswd lois /usr/local/etc/httpd/support/htpasswd ~/auth/.htpasswd ned /usr/local/etc/httpd/support/htpasswd ~/auth/.htpasswd lila
To change a password for an existing username, type:
/usr/local/etc/httpd/support/htpasswd ~/otherdir/.htpasswd username
http://wintermute.ncsa.uiuc.edu:8080/auth-tutorial/tutorial