Basic Authentication is analogous to simply "closing a door" to parts of your Web site. It will prevent the casual or polite users from "opening the door", but will not prevent someone mildly determined to walking in.
Two issues that contribute to the lack of security and privacy are:
| Filename | Description |
|---|---|
| .htaccess |
This file contains the instructions the WWW Server needs in order to implement access control. The directives contained within this file will apply to
all
the files and subdirectories at or below the level of the .htaccess file.
For example, /home/j/h/jharvard/public_html/private/.htaccess will apply to all files contained within the ~jharvard/public_html/private directory (and its subdirectories), but would not be applied to the file ~jharvard/public_html/index.html. This file needs to be readable by the Web Server. See below for sample configurations of .htaccess |
| .htpasswd |
This file contains usernames and encrypted passwords (username:enc_passwd). It is created and managed with the utility, "htpasswd", which can be run from the command line on fas.harvard.edu and ice.fas.harvard.edu.
This file should not lie within your public_html. It should reside at the root level of your home directory (for example, /home/j/h/jharvard/.htpasswd This file needs to be readable by the Web Server. |
| .htgroup |
This file contains group definitions (group_name:member1, member2, ...).
This file should not lie within your public_html. It should reside at the root level of your home directory (for example, /home/j/h/jharvard/.htgroup This file needs to be readable by the Web Server. |
The following .htpasswd and .htgroup files are used:
| Filename | Description |
|---|---|
| /home/w/e/web/.htpasswd |
The .htpasswd was generated by using the utility "htpasswd"
ice% htpasswd Usage: htpasswd [-c] passwordfile username The -c flag creates a new file. ice% htpasswd -c /home/w/e/web/.htpasswd guest Adding password for guest New password: ***** Re-type password: *****Password for "guest" is "guest". Entries for guest2, guest3, and guest4 are created without the "-c" flag, since the .htpasswd file already exists. Contents of file: guest:79WeSn3vYGsKQ guest2:PR4APgA.4CKO. guest3:5DbCMPbSDstj2 guest4:htPnr8jT4bI5E |
| .htgroup |
Contents of file:
VIP: guest, guest4 |
The"AuthName" is the description that is displayed by the browser in the Basic Authentication dialog box.
AuthName "Basic Authentication Tutorial 1" AuthType Basic AuthUserFile /home/w/e/web/.htpasswd require valid-user
Contents of sample .htaccess file:
AuthName "Basic Authentication Tutorial 2" AuthType Basic AuthUserFile /home/w/e/web/.htpasswd require user guest2, guest3
Unauthorized:
guest:guest
guest4:guest4
Contents of .htaccess file:
AuthName "Basic Authentication Tutorial 3" AuthType Basic AuthUserFile /home/w/e/web/.htpasswd AuthGroupFile /home/w/e/web/.htgroup require group VIP
Unauthorized:
guest2:guest2
guest3:guest3
Contents of sample .htaccess file:
order deny,allow deny from all allow from 140.247, 128.103, .harvard.edu
Contents of sample .htaccess file:
order allow,deny allow from all deny from .fas.harvard.edu
Contents of sample .htaccess file:
order deny,allow deny from all allow from .yale.edu AuthType Basic AuthUserFile /home/w/e/web/.htpasswd AuthName "Basic Authentication Tutorial 6" require valid-user satisfy any
Contents of sample .htaccess file:
order deny,allow deny from all allow from .harvard.edu AuthType Basic AuthUserFile /home/w/e/web/.htpasswd AuthName "Basic Authentication Tutorial 7" require valid-user satisfy all
Relevant information can also be found in the Stronghold and Apache documentation: