General Information
If you have an ICS UNIX account, you can create your own personal web page. For more information or help getting started, see Creating Your Own Web Space.The remainder of this document assumes you have already created your own personal web space and that you are familiar with where to locate your web documents and what URLs to use to access those documents.
Access Control Features
ICS runs the Apache Web Server which allows you to control web access to part or all of your personal web space. You can control access to your web space based on the following criteria:
- Username/password-level access authorization.
- Rejection or acceptance of connections based on Internet address of client.
- A combination of the above two methods.
Access control for a given directory is controlled by a file named
.htaccesswhich resides in that directory. The web server consults this file on each access to a document located in that directory or one of its subdirectories.
Note that your web files in your
public_htmldirectory (including the.htaccessfile) must be readable by the web server itself. This means that those files will also be readable by any other ICS UNIX user -- you can't use the web server access control features to prevent local users from reading your web files directly though the network filesystem.
By-Password Authentication
With by-password authentication, web access to your documents is allowed only to users with an authorized username and password.Important Note: There is no correspondence between usernames and passwords on specific UNIX systems (i.e., your UNIX login name and password) 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; it is not necessary to have an actual account on a given UNIX system in order to be validated for access to files which are served from that system and protected with by-password authentication.
So let's suppose you want to restrict files in your
public_html/turkeydirectory to usernamepumpkinand passwordpie. Here's what to do:
- Create a file called
.htaccessin directorypublic_html/turkeythat looks like this:
AuthUserFile /home/yourname/.htpasswd AuthGroupFile /dev/null AuthName ExampleByPassword AuthType Basic <Limit GET> require user pumpkin </Limit>
Note that the password file (
.htpasswd) will be in your home directory, not the directory where your web pages are located. This prevents web clients from accessing this file.Also note that in this case there is no group file, so we specify
/dev/null(the standard UNIX way to say "this file doesn't exist").
AuthNameis called the authorization realm for this directory. It's value can be anything you want. This authorization realm value is displayed by users' web browsers so that they know which username and password to send.
AuthTypeshould always currently beBasic.
- Create the password file
/home/yourname/.htpasswd.The easiest way to do this is to use the
htpasswdprogram. (If you haven't already loaded the apache module, you'll have to load it first to accesshtpasswd.) Do this:
% module load apache % htpasswd -c /home/yourname/.htpasswd pumpkin
Type the password --
pie-- twice as instructed.Check the resulting file to get a warm feeling of self-satisfaction; it should look something like this:
pumpkin:y1ia3tjWkhCK2
That's all. Now try to access a file in
http://www.ics.uci.edu/~yourname/turkey-- your web browser should demand a username and password, and not give you access to the file if you don't enterpumpkinandpie. If you are using a web browser that doesn't handle authentication (which is unlikely, but possible), you will not be able to access the document at all.
How Secure Is It?
The password is passed over the network not encrypted but not as plain text -- it is "uuencoded". Anyone watching packet traffic on the network will not see the password in the clear, but the password will be easily decoded by anyone who happens to catch the right network packet.Your web browser will keep track of any authorization realm names, usernames and passwords that it you asks for. Then, the next time you access a restricted web page in the same authorization realm, your web browser does not have to ask you again for a username and password, it just gives the web server the ones you gave it earlier.
Since your web browser will give out these usernames and passwords to any web site which asks for them, you should not use the same username and password for web-based authentication that you use to login to your computer account.
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:
That's it. Now any user in group
- Add additional users to the directory's
.htpasswdfile.Use the
htpasswdcommand without the-cflag to additional users; e.g.:
% htpasswd /home/yourname/.htpasswd peanuts % htpasswd /home/yourname/.htpasswd almonds % htpasswd /home/yourname/.htpasswd walnuts
- Create a group file.
Call it
/home/yourname/.htgroupand have it look something like this:
my-users: pumpkin peanuts almonds walnuts
...wherepumpkin,peanuts,almonds, andwalnutsare the usernames.
- Then modify the
.htaccessfile in the directory to look like this:
AuthUserFile /home/yourname/.htpasswd AuthGroupFile /home/yourname/.htgroup AuthName ExampleByPassword AuthType Basic <Limit GET> require group my-users </Limit>
Note that
AuthGroupFilenow points to your group file and that groupmy-users(rather than individual userpumpkin) is now required for access.
my-userscan use his/her individual username and password to gain access to directoryturkey.
Internet Address Authentication
With internet address authentication, web access to your documents is allowed or denied to users running web browsers on hosts in particular internet domains.
Let's suppose you want to restrict files in your
public_html/localdirectory to clients running on machines inside domainics.uci.edu.
That's all. Now try to access a file in
- Create a file called
.htaccessin directorypublic_html/localthat looks like this:
AuthUserFile /dev/null AuthGroupFile /dev/null AuthName ExampleAllowFromICS AuthType Basic <Limit GET> order deny,allow deny from all allow from .ics.uci.edu </Limit>
http://www.ics.uci.edu/~yourname/local-- if your web browser is running on a client in theics.uci.edudomain, you should be able to access the page. Clients not in theics.uci.edudomain will receive an error when they try to access the page.
Internet Address Authentication -- Exclusion
Let's suppose you want to restrict files in your
public_html/remotedirectory to clients running on machines not inside theics.uci.edudomain.
That's all. Now try to access a file in
- Create a file called
.htaccessin directorypublic_html/remotethat looks like this:
AuthUserFile /dev/null AuthGroupFile /dev/null AuthName ExampleDenyFromICS AuthType Basic <Limit GET> order allow,deny allow from all deny from .ics.uci.edu </Limit>
http://www.ics.uci.edu/~yourname/remote-- if your web browser is running on a client in theics.uci.edudomain, you should receive an error when you try to access the page. Clients not in theics.uci.edudomain should be able to access the page.
Acknowledgements
This tutorial is based heavily on work done by Ari Luotonen at CERN and Rob McCool at NCSA.
For More Information