1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>Authentication and Authorization - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
12 <script src="../style/scripts/prettify.js" type="text/javascript">
15 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
16 <body id="manual-page"><div id="page-header">
17 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
18 <p class="apache">Apache HTTP Server Version 2.4</p>
19 <img alt="" src="../images/feather.gif" /></div>
20 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
22 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">How-To / Tutorials</a></div><div id="page-content"><div id="preamble"><h1>Authentication and Authorization</h1>
24 <p><span>Available Languages: </span><a href="../en/howto/auth.html" title="English"> en </a> |
25 <a href="../fr/howto/auth.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
26 <a href="../ja/howto/auth.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
27 <a href="../ko/howto/auth.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
28 <a href="../tr/howto/auth.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
31 <p>Authentication is any process by which you verify that
32 someone is who they claim they are. Authorization is any
33 process by which someone is allowed to be where they want to
34 go, or to have information that they want to have.</p>
36 <p>For general access control, see the <a href="access.html">Access
37 Control How-To</a>.</p>
39 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#related">Related Modules and Directives</a></li>
40 <li><img alt="" src="../images/down.gif" /> <a href="#introduction">Introduction</a></li>
41 <li><img alt="" src="../images/down.gif" /> <a href="#theprerequisites">The Prerequisites</a></li>
42 <li><img alt="" src="../images/down.gif" /> <a href="#gettingitworking">Getting it working</a></li>
43 <li><img alt="" src="../images/down.gif" /> <a href="#lettingmorethanonepersonin">Letting more than one
45 <li><img alt="" src="../images/down.gif" /> <a href="#possibleproblems">Possible problems</a></li>
46 <li><img alt="" src="../images/down.gif" /> <a href="#dbmdbd">Alternate password storage</a></li>
47 <li><img alt="" src="../images/down.gif" /> <a href="#multprovider">Using multiple providers</a></li>
48 <li><img alt="" src="../images/down.gif" /> <a href="#beyond">Beyond just authorization</a></li>
49 <li><img alt="" src="../images/down.gif" /> <a href="#socache">Authentication Cacheing</a></li>
50 <li><img alt="" src="../images/down.gif" /> <a href="#moreinformation">More information</a></li>
51 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
52 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
54 <h2><a name="related" id="related">Related Modules and Directives</a></h2>
56 <p>There are three types of modules involved in the authentication and
57 authorization process. You will usually need to choose at least one
58 module from each group.</p>
61 <li>Authentication type (see the
62 <code class="directive"><a href="../mod/mod_authn_core.html#authtype">AuthType</a></code> directive)
64 <li><code class="module"><a href="../mod/mod_auth_basic.html">mod_auth_basic</a></code></li>
65 <li><code class="module"><a href="../mod/mod_auth_digest.html">mod_auth_digest</a></code></li>
68 <li>Authentication provider (see the
69 <code class="directive"><a href="../mod/mod_auth_basic.html#authbasicprovider">AuthBasicProvider</a></code> and
70 <code class="directive"><a href="../mod/mod_auth_digest.html#authdigestprovider">AuthDigestProvider</a></code> directives)
73 <li><code class="module"><a href="../mod/mod_authn_anon.html">mod_authn_anon</a></code></li>
74 <li><code class="module"><a href="../mod/mod_authn_dbd.html">mod_authn_dbd</a></code></li>
75 <li><code class="module"><a href="../mod/mod_authn_dbm.html">mod_authn_dbm</a></code></li>
76 <li><code class="module"><a href="../mod/mod_authn_file.html">mod_authn_file</a></code></li>
77 <li><code class="module"><a href="../mod/mod_authnz_ldap.html">mod_authnz_ldap</a></code></li>
78 <li><code class="module"><a href="../mod/mod_authn_socache.html">mod_authn_socache</a></code></li>
81 <li>Authorization (see the
82 <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code> directive)
84 <li><code class="module"><a href="../mod/mod_authnz_ldap.html">mod_authnz_ldap</a></code></li>
85 <li><code class="module"><a href="../mod/mod_authz_dbd.html">mod_authz_dbd</a></code></li>
86 <li><code class="module"><a href="../mod/mod_authz_dbm.html">mod_authz_dbm</a></code></li>
87 <li><code class="module"><a href="../mod/mod_authz_groupfile.html">mod_authz_groupfile</a></code></li>
88 <li><code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code></li>
89 <li><code class="module"><a href="../mod/mod_authz_owner.html">mod_authz_owner</a></code></li>
90 <li><code class="module"><a href="../mod/mod_authz_user.html">mod_authz_user</a></code></li>
95 <p>In addition to these modules, there are also
96 <code class="module"><a href="../mod/mod_authn_core.html">mod_authn_core</a></code> and
97 <code class="module"><a href="../mod/mod_authz_core.html">mod_authz_core</a></code>. These module implement core
98 directives that are core to all auth modules.</p>
100 <p>The module <code class="module"><a href="../mod/mod_authnz_ldap.html">mod_authnz_ldap</a></code> is both an
101 authentication and authorization provider. The module
102 <code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code> provides authorization
103 and access control based on hostname, IP address or characteristics
104 of the request, but is not part of the authentication provider
105 system. For backwards compatibility with the mod_access, there is
106 a new module <code class="module"><a href="../mod/mod_access_compat.html">mod_access_compat</a></code>.</p>
108 <p>You probably also want to take a look at the <a href="access.html">Access Control</a> howto, which discusses the
109 various ways to control access to your server.</p>
111 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
112 <div class="section">
113 <h2><a name="introduction" id="introduction">Introduction</a></h2>
114 <p>If you have information on your web site that is sensitive
115 or intended for only a small group of people, the techniques in
116 this article will help you make sure that the people that see
117 those pages are the people that you wanted to see them.</p>
119 <p>This article covers the "standard" way of protecting parts
120 of your web site that most of you are going to use.</p>
122 <div class="note"><h3>Note:</h3>
123 <p>If your data really needs to be secure, consider using
124 <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> in addition to any authentication.</p>
126 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
127 <div class="section">
128 <h2><a name="theprerequisites" id="theprerequisites">The Prerequisites</a></h2>
129 <p>The directives discussed in this article will need to go
130 either in your main server configuration file (typically in a
131 <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> section), or
132 in per-directory configuration files (<code>.htaccess</code> files).</p>
134 <p>If you plan to use <code>.htaccess</code> files, you will
135 need to have a server configuration that permits putting
136 authentication directives in these files. This is done with the
137 <code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code> directive, which
138 specifies which directives, if any, may be put in per-directory
139 configuration files.</p>
141 <p>Since we're talking here about authentication, you will need
142 an <code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code> directive like the
145 <pre class="prettyprint lang-config">AllowOverride AuthConfig</pre>
148 <p>Or, if you are just going to put the directives directly in
149 your main server configuration file, you will of course need to
150 have write permission to that file.</p>
152 <p>And you'll need to know a little bit about the directory
153 structure of your server, in order to know where some files are
154 kept. This should not be terribly difficult, and I'll try to
155 make this clear when we come to that point.</p>
157 <p>You will also need to make sure that the modules
158 <code class="module"><a href="../mod/mod_authn_core.html">mod_authn_core</a></code> and <code class="module"><a href="../mod/mod_authz_core.html">mod_authz_core</a></code>
159 have either been built into the httpd binary or loaded by the
160 httpd.conf configuration file. Both of these modules provide core
161 directives and functionality that are critical to the configuration
162 and use of authentication and authorization in the web server.</p>
163 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
164 <div class="section">
165 <h2><a name="gettingitworking" id="gettingitworking">Getting it working</a></h2>
166 <p>Here's the basics of password protecting a directory on your
169 <p>First, you need to create a password file. Exactly how you do
170 this will vary depending on what authentication provider you have
171 chosen. More on that later. To start with, we'll use a text password
174 <p>This file should be
175 placed somewhere not accessible from the web. This is so that
176 folks cannot download the password file. For example, if your
177 documents are served out of <code>/usr/local/apache/htdocs</code> you
178 might want to put the password file(s) in
179 <code>/usr/local/apache/passwd</code>.</p>
181 <p>To create the file, use the <code class="program"><a href="../programs/htpasswd.html">htpasswd</a></code> utility that
182 came with Apache. This will be located in the <code>bin</code> directory
183 of wherever you installed Apache. If you have installed Apache from
184 a third-party package, it may be in your execution path.</p>
186 <p>To create the file, type:</p>
188 <div class="example"><p><code>
189 htpasswd -c /usr/local/apache/passwd/passwords rbowen
192 <p><code class="program"><a href="../programs/htpasswd.html">htpasswd</a></code> will ask you for the password, and
193 then ask you to type it again to confirm it:</p>
195 <div class="example"><p><code>
196 # htpasswd -c /usr/local/apache/passwd/passwords rbowen<br />
197 New password: mypassword<br />
198 Re-type new password: mypassword<br />
199 Adding password for user rbowen
202 <p>If <code class="program"><a href="../programs/htpasswd.html">htpasswd</a></code> is not in your path, of course
203 you'll have to type the full path to the file to get it to run.
204 With a default installation, it's located at
205 <code>/usr/local/apache2/bin/htpasswd</code></p>
207 <p>Next, you'll need to configure the server to request a
208 password and tell the server which users are allowed access.
209 You can do this either by editing the <code>httpd.conf</code>
210 file or using an <code>.htaccess</code> file. For example, if
211 you wish to protect the directory
212 <code>/usr/local/apache/htdocs/secret</code>, you can use the
213 following directives, either placed in the file
214 <code>/usr/local/apache/htdocs/secret/.htaccess</code>, or
215 placed in <code>httpd.conf</code> inside a <Directory
216 /usr/local/apache/htdocs/secret> section.</p>
218 <pre class="prettyprint lang-config">
220 AuthName "Restricted Files"
221 # (Following line optional)
222 AuthBasicProvider file
223 AuthUserFile /usr/local/apache/passwd/passwords
228 <p>Let's examine each of those directives individually. The <code class="directive"><a href="../mod/mod_authn_core.html#authtype">AuthType</a></code> directive selects
229 that method that is used to authenticate the user. The most
230 common method is <code>Basic</code>, and this is the method
231 implemented by <code class="module"><a href="../mod/mod_auth_basic.html">mod_auth_basic</a></code>. It is important to be aware,
232 however, that Basic authentication sends the password from the client to
233 the server unencrypted. This method should therefore not be used for
234 highly sensitive data, unless accompanied by <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>.
235 Apache supports one other authentication method:
236 <code>AuthType Digest</code>. This method is implemented by <code class="module"><a href="../mod/mod_auth_digest.html">mod_auth_digest</a></code> and was intended to be more secure. This is no
237 longer the case and the connection should be encrypted with <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> instead.</p>
239 <p>The <code class="directive"><a href="../mod/mod_authn_core.html#authname">AuthName</a></code> directive sets
240 the <dfn>Realm</dfn> to be used in the authentication. The realm serves
241 two major functions. First, the client often presents this information to
242 the user as part of the password dialog box. Second, it is used by the
243 client to determine what password to send for a given authenticated
246 <p>So, for example, once a client has authenticated in the
247 <code>"Restricted Files"</code> area, it will automatically
248 retry the same password for any area on the same server that is
249 marked with the <code>"Restricted Files"</code> Realm.
250 Therefore, you can prevent a user from being prompted more than
251 once for a password by letting multiple restricted areas share
252 the same realm. Of course, for security reasons, the client
253 will always need to ask again for the password whenever the
254 hostname of the server changes.</p>
256 <p>The <code class="directive"><a href="../mod/mod_auth_basic.html#authbasicprovider">AuthBasicProvider</a></code> is,
257 in this case, optional, since <code>file</code> is the default value
258 for this directive. You'll need to use this directive if you are
259 choosing a different source for authentication, such as
260 <code class="module"><a href="../mod/mod_authn_dbm.html">mod_authn_dbm</a></code> or <code class="module"><a href="../mod/mod_authn_dbd.html">mod_authn_dbd</a></code>.</p>
262 <p>The <code class="directive"><a href="../mod/mod_authn_file.html#authuserfile">AuthUserFile</a></code>
263 directive sets the path to the password file that we just
264 created with <code class="program"><a href="../programs/htpasswd.html">htpasswd</a></code>. If you have a large number
265 of users, it can be quite slow to search through a plain text
266 file to authenticate the user on each request. Apache also has
267 the ability to store user information in fast database files.
268 The <code class="module"><a href="../mod/mod_authn_dbm.html">mod_authn_dbm</a></code> module provides the <code class="directive"><a href="../mod/mod_authn_dbm.html#authdbmuserfile">AuthDBMUserFile</a></code> directive. These
269 files can be created and manipulated with the <code class="program"><a href="../programs/dbmmanage.html">dbmmanage</a></code> and <code class="program"><a href="../programs/htdbm.html">htdbm</a></code> programs. Many
270 other types of authentication options are available from third
271 party modules in the <a href="http://modules.apache.org/">Apache Modules
274 <p>Finally, the <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code>
275 directive provides the authorization part of the process by
276 setting the user that is allowed to access this region of the
277 server. In the next section, we discuss various ways to use the
278 <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code> directive.</p>
279 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
280 <div class="section">
281 <h2><a name="lettingmorethanonepersonin" id="lettingmorethanonepersonin">Letting more than one
283 <p>The directives above only let one person (specifically
284 someone with a username of <code>rbowen</code>) into the
285 directory. In most cases, you'll want to let more than one
286 person in. This is where the <code class="directive"><a href="../mod/mod_authz_groupfile.html#authgroupfile">AuthGroupFile</a></code> comes in.</p>
288 <p>If you want to let more than one person in, you'll need to
289 create a group file that associates group names with a list of
290 users in that group. The format of this file is pretty simple,
291 and you can create it with your favorite editor. The contents
292 of the file will look like this:</p>
294 <div class="example"><p><code>
295 GroupName: rbowen dpitts sungo rshersey
298 <p>That's just a list of the members of the group in a long
299 line separated by spaces.</p>
301 <p>To add a user to your already existing password file,
304 <div class="example"><p><code>
305 htpasswd /usr/local/apache/passwd/passwords dpitts
308 <p>You'll get the same response as before, but it will be
309 appended to the existing file, rather than creating a new file.
310 (It's the <code>-c</code> that makes it create a new password
313 <p>Now, you need to modify your <code>.htaccess</code> file or
314 <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> block
315 to look like the following:</p>
317 <pre class="prettyprint lang-config">
319 AuthName "By Invitation Only"
321 AuthBasicProvider file
322 AuthUserFile /usr/local/apache/passwd/passwords
323 AuthGroupFile /usr/local/apache/passwd/groups
324 Require group GroupName
328 <p>Now, anyone that is listed in the group <code>GroupName</code>,
329 and has an entry in the <code>password</code> file, will be let in, if
330 they type the correct password.</p>
332 <p>There's another way to let multiple users in that is less
333 specific. Rather than creating a group file, you can just use
334 the following directive:</p>
336 <pre class="prettyprint lang-config">Require valid-user</pre>
339 <p>Using that rather than the <code>Require user rbowen</code>
340 line will allow anyone in that is listed in the password file,
341 and who correctly enters their password.</p>
342 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
343 <div class="section">
344 <h2><a name="possibleproblems" id="possibleproblems">Possible problems</a></h2>
345 <p>Because of the way that Basic authentication is specified,
346 your username and password must be verified every time you
347 request a document from the server. This is even if you're
348 reloading the same page, and for every image on the page (if
349 they come from a protected directory). As you can imagine, this
350 slows things down a little. The amount that it slows things
351 down is proportional to the size of the password file, because
352 it has to open up that file, and go down the list of users
353 until it gets to your name. And it has to do this every time a
356 <p>A consequence of this is that there's a practical limit to
357 how many users you can put in one password file. This limit
358 will vary depending on the performance of your particular
359 server machine, but you can expect to see slowdowns once you
360 get above a few hundred entries, and may wish to consider a
361 different authentication method at that time.</p>
362 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
363 <div class="section">
364 <h2><a name="dbmdbd" id="dbmdbd">Alternate password storage</a></h2>
366 <p>Because storing passwords in plain text files has the above
367 problems, you may wish to store your passwords somewhere else, such
368 as in a database.</p>
370 <p><code class="module"><a href="../mod/mod_authn_dbm.html">mod_authn_dbm</a></code> and <code class="module"><a href="../mod/mod_authn_dbd.html">mod_authn_dbd</a></code> are two
371 modules which make this possible. Rather than selecting <code><code class="directive"><a href="../mod/mod_auth_basic.html#authbasicprovider">AuthBasicProvider</a></code> file</code>, instead
372 you can choose <code>dbm</code> or <code>dbd</code> as your storage
375 <p>To select a dbm file rather than a text file, for example:</p>
377 <pre class="prettyprint lang-config">
378 <Directory /www/docs/private>
381 AuthBasicProvider dbm
382 AuthDBMUserFile /www/passwords/passwd.dbm
388 <p>Other options are available. Consult the
389 <code class="module"><a href="../mod/mod_authn_dbm.html">mod_authn_dbm</a></code> documentation for more details.</p>
390 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
391 <div class="section">
392 <h2><a name="multprovider" id="multprovider">Using multiple providers</a></h2>
394 <p>With the introduction of the new provider based authentication and
395 authorization architecture, you are no longer locked into a single
396 authentication or authorization method. In fact any number of the
397 providers can be mixed and matched to provide you with exactly the
398 scheme that meets your needs. In the following example, both the
399 file and LDAP based authentication providers are being used.</p>
401 <pre class="prettyprint lang-config">
402 <Directory /www/docs/private>
405 AuthBasicProvider file ldap
406 AuthUserFile /usr/local/apache/passwd/passwords
407 AuthLDAPURL ldap://ldaphost/o=yourorg
413 <p>In this example the file provider will attempt to authenticate
414 the user first. If it is unable to authenticate the user, the LDAP
415 provider will be called. This allows the scope of authentication
416 to be broadened if your organization implements more than
417 one type of authentication store. Other authentication and authorization
418 scenarios may include mixing one type of authentication with a
419 different type of authorization. For example, authenticating against
420 a password file yet authorizing against an LDAP directory.</p>
422 <p>Just as multiple authentication providers can be implemented, multiple
423 authorization methods can also be used. In this example both file group
424 authorization as well as LDAP group authorization is being used.</p>
426 <pre class="prettyprint lang-config">
427 <Directory /www/docs/private>
430 AuthBasicProvider file
431 AuthUserFile /usr/local/apache/passwd/passwords
432 AuthLDAPURL ldap://ldaphost/o=yourorg
433 AuthGroupFile /usr/local/apache/passwd/groups
434 Require group GroupName
435 Require ldap-group cn=mygroup,o=yourorg
440 <p>To take authorization a little further, authorization container
442 <code class="directive"><a href="../mod/mod_authz_core.html#requireall"><RequireAll></a></code>
444 <code class="directive"><a href="../mod/mod_authz_core.html#requireany"><RequireAny></a></code>
445 allow logic to be applied so that the order in which authorization
446 is handled can be completely controled through the configuration.
447 See <a href="../mod/mod_authz_core.html#logic">Authorization
448 Containers</a> for an example of they may be applied.</p>
450 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
451 <div class="section">
452 <h2><a name="beyond" id="beyond">Beyond just authorization</a></h2>
454 <p>The way that authorization can be apply is now much more flexible
455 than just a single check against a single data store. Ordering, logic
456 and choosing how authorization will be done is now possible.</p>
458 <h3><a name="authandororder" id="authandororder">Applying logic and ordering</a></h3>
459 <p>Controling how and in what order authorization will be applied
460 has been a bit of a mystery in the past. In Apache 2.2 a provider-based
461 authentication mechanism was introduced to decouple the actual
462 authentication process from authorization and supporting functionality.
463 One of the side benefits was that authentication providers could be
464 configured and called in a specific order which didn't depend on the
465 load order of the auth module itself. This same provider based mechanism
466 has been brought forward into authorization as well. What this means is
467 that the <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code> directive
468 not only specifies which authorization methods should be used, it also
469 specifies the order in which they are called. Multiple authorization
470 methods are called in the same order in which the
471 <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code> directives
472 appear in the configuration.</p>
474 <p>With the introduction of authorization container directives
476 <code class="directive"><a href="../mod/mod_authz_core.html#requireall"><RequireAll></a></code>
478 <code class="directive"><a href="../mod/mod_authz_core.html#requireany"><RequireAny></a></code>,
479 the configuration also has control over when the
480 authorization methods are called and what criteria determines when
481 access is granted. See
482 <a href="../mod/mod_authz_core.html#logic">Authorization Containers</a>
483 for an example of how they may be used to express complex
484 authorization logic.</p>
487 <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code>
488 directives are handled as though contained within a
489 <code class="directive"><a href="../mod/mod_authz_core.html#requireany"><RequireAny></a></code>
490 container directive. In other words, if
491 any of the specified authorization methods succeed, then authorization
496 <h3><a name="reqaccessctrl" id="reqaccessctrl">Using authorization providers for access control</a></h3>
497 <p>Authentication by username and password is only part of the
498 story. Frequently you want to let people in based on something
499 other than who they are. Something such as where they are
502 <p>The authorization providers <code class="directive"><a href="../mod/mod_authz_host.html#all">
503 all</a></code>, <code class="directive"><a href="../mod/mod_authz_host.html#env">
504 env</a></code>, <code class="directive"><a href="../mod/mod_authz_host.html#host">
505 host</a></code> and <code class="directive"><a href="../mod/mod_authz_host.html#ip">
506 ip</a></code> let you allow or deny access based other host based
507 criteria such as host name or ip address of the machine requesting
510 <p>The usage of these providers is specified through the
511 <code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code> directive.
512 This directive registers the authorization providers
513 that will be called during the authorization stage of the request
514 processing. For example:</p>
516 <pre class="prettyprint lang-config">Require ip <var>address</var></pre>
519 <p>where <var>address</var> is an IP address (or a partial IP
522 <pre class="prettyprint lang-config">Require host <var>domain_name</var></pre>
525 <p>where <var>domain_name</var> is a fully qualified domain name
526 (or a partial domain name); you may provide multiple addresses or
527 domain names, if desired.</p>
529 <p>For example, if you have someone spamming your message
530 board, and you want to keep them out, you could do the
533 <pre class="prettyprint lang-config">
536 Require not ip 10.252.46.165
541 <p>Visitors coming from that address will not be able to see
542 the content covered by this directive. If, instead, you have a
543 machine name, rather than an IP address, you can use that.</p>
545 <pre class="prettyprint lang-config">
548 Require not host host.example.com
553 <p>And, if you'd like to block access from an entire domain,
554 you can specify just part of an address or domain name:</p>
556 <pre class="prettyprint lang-config">
559 Require not ip 192.168.205
560 Require not host phishers.example.com moreidiots.example
566 <p>Using <code class="directive"><a href="../mod/mod_authz_core.html#requireall"><RequireAll></a></code>
567 with multiple <code class="directive"><a href="../mod/mod_authz_core.html#require"><Require></a></code> directives, each negated with <code>not</code>,
568 will only allow access, if all of negated conditions are true. In other words,
569 access will be blocked, if any of the negated conditions fails.</p>
573 <h3><a name="filesystem" id="filesystem">Access Control backwards compatibility</a></h3>
574 <p>One of the side effects of adopting a provider based mechanism for
575 authentication is that the need for the previous access control directives
576 <code class="directive"><a href="../mod/mod_access_compat.html#order">Order</a></code>,
577 <code class="directive"><a href="../mod/mod_access_compat.html#allow">Allow</a></code>,
578 <code class="directive"><a href="../mod/mod_access_compat.html#deny">Deny</a></code> and
579 <code class="directive"><a href="../mod/mod_access_compat.html#satisfy">Satisfy</a></code> are no longer needed.
580 However to provide backwards compatibility for older configurations, these
581 directives have been moved to the <code class="module"><a href="../mod/mod_access_compat.html">mod_access_compat</a></code> module.</p>
584 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
585 <div class="section">
586 <h2><a name="socache" id="socache">Authentication Cacheing</a></h2>
587 <p>There may be times when authentication puts an unacceptable load
588 on a provider or on your network. This is most likely to affect users
589 of <code class="module"><a href="../mod/mod_authn_dbd.html">mod_authn_dbd</a></code> (or third-party/custom providers).
590 To deal with this, HTTPD 2.3/2.4 introduces a new cacheing provider
591 <code class="module"><a href="../mod/mod_authn_socache.html">mod_authn_socache</a></code> to cache credentials and reduce
592 the load on the origin provider(s).</p>
593 <p>This may offer a substantial performance boost to some users.</p>
594 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
595 <div class="section">
596 <h2><a name="moreinformation" id="moreinformation">More information</a></h2>
597 <p>You should also read the documentation for
598 <code class="module"><a href="../mod/mod_auth_basic.html">mod_auth_basic</a></code> and <code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code> which
599 contain some more information about how this all works.
600 The directive <code class="directive"><a href="../mod/mod_authn_core.html#<authnprovideralias>"><AuthnProviderAlias></a></code>
601 can also help in simplifying certain authentication configurations.</p>
603 <p>The various ciphers supported by Apache for authentication data are
604 explained in <a href="../misc/password_encryptions.html">Password
607 <p>And you may want to look at the <a href="access.html">Access
608 Control</a> howto, which discusses a number of related topics.</p>
611 <div class="bottomlang">
612 <p><span>Available Languages: </span><a href="../en/howto/auth.html" title="English"> en </a> |
613 <a href="../fr/howto/auth.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
614 <a href="../ja/howto/auth.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
615 <a href="../ko/howto/auth.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
616 <a href="../tr/howto/auth.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
617 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
618 <script type="text/javascript"><!--//--><![CDATA[//><!--
619 var comments_shortname = 'httpd';
620 var comments_identifier = 'http://httpd.apache.org/docs/2.4/howto/auth.html';
622 if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
623 d.write('<div id="comments_thread"><\/div>');
624 var s = d.createElement('script');
625 s.type = 'text/javascript';
627 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
628 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
631 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
633 })(window, document);
634 //--><!]]></script></div><div id="footer">
635 <p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
636 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
637 if (typeof(prettyPrint) !== 'undefined') {