]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_authz_dbd.xml
Authz refactoring
[apache] / docs / manual / mod / mod_authz_dbd.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Copyright 2002-2005 The Apache Software Foundation or its licensors, as
8  applicable.
9
10  Licensed under the Apache License, Version 2.0 (the "License");
11  you may not use this file except in compliance with the License.
12  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <modulesynopsis metafile="mod_authz_dbd.xml.meta">
24
25 <name>mod_authz_dbd</name>
26 <description>Group Authorization and Login using SQL</description>
27 <status>Extension</status>
28 <sourcefile>mod_authz_dbd.c</sourcefile>
29 <identifier>authz_dbd_module</identifier>
30 <compatibility>Available in Apache 2.2 and later</compatibility>
31
32 <summary>
33     <p>This module provides authorization capabilities so that
34        authenticated users can be allowed or denied access to portions
35        of the web site by group membership. It also provides
36        database/backend login/logout in conjunction with
37        <module>mod_authn_dbd</module>.</p>
38 </summary>
39
40 <seealso><directive module="core">Require</directive></seealso>
41 <seealso><directive module="mod_dbd">DBDriver</directive></seealso>
42 <seealso><directive module="mod_dbd">DBDParams</directive></seealso>
43
44 <section id="login">
45 <title>Database Login</title>
46 <p>In addition to the standard authz function of checking group
47 membership, this module provides database Login/Logout capability.
48 Specifically, we can maintain a logged in/logged out status in
49 the database, and control the status via designated URLs (subject
50 of course to users supplying the necessary credentials).</p>
51 <p>This works by defining two special
52 <directive module="core">Require</directive> types:
53 <code>Require dbd-login</code> and <code>Require dbd-logout</code>.
54 For usage details, see the configuration example below.</p>
55 </section>
56
57 <section id="client">
58 <title>Client Login</title>
59 <p>In conjunction with server login/logout, we may wish to implement
60 clientside login/out, for example by setting and unsetting a cookie
61 or other such token.  Although this is not the business of an authz
62 module, client session management software should be able to tie its
63 operation in to database login/logout.  To support this,
64 <module>mod_authz_dbd</module> exports an optional hook that will
65 be run whenever a user successfully logs into or out of the database.
66 Session management modules can use the hook to implement functions
67 to start and end a client session.</p>
68 </section>
69
70 <section id="example">
71 <title>Configuration Example</title>
72 <example><pre><code>
73 # DBD Configuration
74 DBDriver oracle
75 DBDParams "dbname=apacheauth user=apache pass=xxxxxx"
76
77 DBDMin  4
78 DBDKeep 8
79 DBDMax  20
80 DBDExptime 300
81
82 &lt;Directory /usr/www/my.site/team-private/&gt;
83    # authn with mod_authn_dbd
84    AuthType Basic
85    AuthName Team
86    AuthBasicProvider dbd
87    AuthDBDUserPWQuery "SELECT pass FROM authn WHERE user = %s AND login = true"
88
89    # Require dbd-group and authz_dbd implementation
90    Require dbd-group team
91    AuthzDBDQuery "SELECT group FROM authz WHERE user = %s"
92
93    # When a user fails to authn/authz, invite them to login
94    ErrorDocument 401 /team-private/login-form.html
95
96    &lt;Files login.html&gt;
97       # Don't require that we're already logged in!
98       AuthDBDUserPWQuery "SELECT pass FROM authn WHERE user = %s"
99
100       # dbd-login action executes a query to set our own state
101       Require dbd-login
102       AuthzDBDQuery "UPDATE authn SET login = true WHERE user = %s"
103
104       # Return user to referring page (if any) on successful login
105       AuthzDBDLoginToReferer On
106    &lt;/Files&gt;
107
108    &lt;Files logout.html&gt;
109       # dbd-logout action executes a query to set our own state
110       Require dbd-logout
111       AuthzDBDQuery "UPDATE authn SET login = false WHERE user = %s"
112    &lt;/Files&gt;
113 &lt;/Directory&gt;
114 </code></pre>
115 </example>
116 </section>
117
118 <directivesynopsis>
119 <name>AuthzDBDQuery</name>
120 <description>Specify the SQL Query for the required operation</description>
121 <syntax>AuthzDBDQuery SQL-Query</syntax>
122 <contextlist><context>directory</context></contextlist>
123
124 <usage>
125     <p>The <directive>AuthzDBDQuery</directive> specifies an SQL
126     query to run.  The purpose of the query depends on the
127     <directive module="core">Require</directive> directive in
128     effect.</p>
129     <ul>
130     <li>With <code>Require dbd-group</code>, it specifies a query
131     to look up groups for the current user.  This is the standard
132     functionality of other authz modules such as
133     <module>mod_authz_file</module> and <module>mod_authz_dbm</module>.
134     In this case it will typically take the form<br/>
135     <code>AuthzDBDQuery "SELECT group FROM groups WHERE user= %s"</code>
136     </li>
137     <li>With <code>Require dbd-login</code> or <code>Require dbd-logout</code>,
138     it will never deny access, but will instead execute an SQL Query
139     designed to log the user (who must already be authenticated with
140     <module>mod_authn_dbd</module>) in or out.  Such a query will
141     typically take the form<br/>
142     <code>AuthzDBDQuery "UPDATE authn SET login = true WHERE user = %s"</code>
143     </li>
144     </ul>
145 </usage>
146 </directivesynopsis>
147
148 <directivesynopsis>
149 <name>AuthzDBDRedirectQuery</name>
150 <description>Specify a query to look up a login page for the user</description>
151 <syntax>AuthzDBDRedirectQuery SQL-Query</syntax>
152 <contextlist><context>directory</context></contextlist>
153
154 <usage>
155     <p>Specifies an optional query to use after successful login
156     (or logout) to redirect the user to a page, which may be
157     specific to the user.  Such a query will take the form<br/>
158     <code>AuthzDBDRedirectQuery "SELECT userpage FROM userpages WHERE user = %s"</code>
159     </p>
160     <p>Note that <directive>AuthzDBDLoginToReferer</directive> takes
161     precedence if both are set.</p>
162 </usage>
163 </directivesynopsis>
164
165 <directivesynopsis>
166 <name>AuthzDBDLoginToReferer</name>
167 <description>Determines whether to redirect the Client to the Referring
168 page on successful login or logout if a <code>Referer</code> request
169 header is present</description>
170 <syntax>AuthzDBDLoginToReferer On|Off</syntax>
171 <default>AuthzDBDLoginToReferer Off</default>
172 <contextlist><context>directory</context></contextlist>
173
174 <usage>
175     <p>In conjunction with <code>Require dbd-login</code> or
176     <code>Require dbd-logout</code>, this provides the option to
177     redirect the client back to the Referring page (the URL in
178     the <code>Referer</code> HTTP request header, if present.
179     When there is no <code>Referer</code> header,
180     <code>AuthzDBDLoginToReferer On</code> will be ignored.</p>
181 </usage>
182 </directivesynopsis>
183
184 </modulesynopsis>