auth.html revision 6f912b4ad14f622aa8d57f887c8c745e13ff6dbf
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <meta name="generator" content="HTML Tidy, see www.w3.org" />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <link rev="made" href="mailto:rbowen@rcbowen.com" />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <!--#include virtual="header.html" -->
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a id="__index__" name="__index__"></a> <!-- INDEX BEGIN -->
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <li><a href="#introduction">Introduction</a></li>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <li><a href="#theprerequisites">The prerequisites</a></li>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <li><a href="#gettingitworking">Getting it working</a></li>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <li><a href="#lettingmorethanonepersonin">Letting more
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <li><a href="#possibleproblems">Possible problems</a></li>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <li><a href="#whatotherneatstuffcanido">What other neat
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <li><a href="#moreinformation">More information</a></li>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <!-- INDEX END -->
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <td valign="top"><strong>Related Modules</strong><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a href="/mod/mod_access.html">mod_access</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <td valign="top"><strong>Related Directives</strong><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a href="/mod/mod_access.html#allow">Allow</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami href="/mod/mod_auth.html#authgroupfile">AuthGroupFile</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a href="/mod/core.html#authname">AuthName</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a href="/mod/core.html#authtype">AuthType</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami href="/mod/mod_auth.html#authuserfile">AuthUserFile</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a href="/mod/mod_access.html#deny">Deny</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a href="/mod/core.html#options">Options</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <a href="/mod/core.html#require">Require</a><br />
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>Authentication is any process by which you verify that
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami someone is who they claim they are. Authorization is any
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami process by which someone is allowed to be where they want to
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami go, or to have information that they want to have.</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>If you have information on your web site that is sensitive
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami or intended for only a small group of people, the techniques in
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami this article will help you make sure that the people that see
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami those pages are the people that you wanted to see them.</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>This article covers the "standard" way of protecting parts
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami of your web site that most of you are going to use.</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <h2><a id="theprerequisites" name="theprerequisites">The
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>The directives discussed in this article will need to go
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami either in your main server configuration file (typically in a
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <Directory> section), or in per-directory configuration
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>If you plan to use <code>.htaccess</code> files, you will
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami need to have a server configuration that permits putting
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami authentication directives in these files. This is done with the
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami href="/mod/core.html#allowoverride">AllowOverride</a></code>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami directive, which specifies which directives, if any, may be put
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami in per-directory configuration files.</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>Since we're talking here about authentication, you will need
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami an <code>AllowOverride</code> directive like the following:</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami AllowOverride AuthConfig
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>Or, if you are just going to put the directives directly in
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami your main server configuration file, you will of course need to
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami have write permission to that file.</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>And you'll need to know a little bit about the directory
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami structure of your server, in order to know where some files are
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami kept. This should not be terribly difficult, and I'll try to
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami make this clear when we come to that point.</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami name="gettingitworking">Getting it working</a></h2>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>Here's the basics of password protecting a directory on your
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>You'll need to create a password file. This file should be
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami placed somewhere not accessible from the web. This is so that
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami folks cannot download the password file. For example, if your
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami documents are served out of
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <code>/usr/local/apache/htdocs</code> you might want to put the
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami password file(s) in <code>/usr/local/apache/passwd</code>.</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami href="/programs/htpasswd.html">htpasswd</a> utility that came
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami with Apache. This be located in the <code>bin</code> directory
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami of wherever you installed Apache. To create the file, type:</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami htpasswd -c /usr/local/apache/passwd/password rbowen
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p><code>htpasswd</code> will ask you for the password, and
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami then ask you to type it again to confirm it:</p>
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami # htpasswd -c /usr/local/apache/passwd/passwords rbowen
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami New password: mypassword
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami Re-type new password: mypassword
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami Adding password for user rbowen
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami <p>If <code>htpasswd</code> is not in your path, of course
placed in httpd.conf inside a <Directory
href="http://modules.apache.org/">Apache Modules
deny from host.example.com
allow from dev.example.com