]> granicus.if.org Git - apache/commitdiff
Merge r1554195 from trunk:
authorJim Jagielski <jim@apache.org>
Sun, 5 Jan 2014 16:13:20 +0000 (16:13 +0000)
committerJim Jagielski <jim@apache.org>
Sun, 5 Jan 2014 16:13:20 +0000 (16:13 +0000)
mod_authz_user: Support the expression parser within the require directives.

Submitted by: minfrin
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1555548 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_authz_user.xml
modules/aaa/mod_authz_user.c

diff --git a/CHANGES b/CHANGES
index b61d12795b9af43ca71b191de9fcab7ebfeaba81..dd980233f2e3086719832439299453a4d5c982d3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,16 +2,19 @@
 
 Changes with Apache 2.4.8
 
-  *) mod_authnz_host: Support the expression parser within the require
+  *) mod_authz_user: Support the expression parser within the require
      directives. [Graham Leggett]
 
-  *) mod_authnz_groupfile: Support the expression parser within the require
+  *) mod_authz_host: Support the expression parser within the require
      directives. [Graham Leggett]
 
-  *) mod_authnz_dbm: Support the expression parser within the require
+  *) mod_authz_groupfile: Support the expression parser within the require
      directives. [Graham Leggett]
 
-  *) mod_authnz_dbd: Support the expression parser within the require
+  *) mod_authz_dbm: Support the expression parser within the require
+     directives. [Graham Leggett]
+
+  *) mod_authz_dbd: Support the expression parser within the require
      directives. [Graham Leggett]
 
   *) mod_authnz_ldap: Support the expression parser within the require
diff --git a/STATUS b/STATUS
index 2790a4251527ca0266a172a4e1ebaa4543b56e9e..158d4e17bfccf491df0852ee51120773c95aff39 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -98,11 +98,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  * mod_authz_user: Support the expression parser within the require directives.
-    trunk patch: http://svn.apache.org/r1554195
-    2.4.x patch: trunk works (modulo CHANGES and log-message-tags)
-    +1: minfrin, jim, covener
-
   * core: Support named groups and backreferences within the LocationMatch,
     DirectoryMatch, FilesMatch and ProxyMatch directives.
     trunk patch: http://svn.apache.org/r1554300
index fea8c72d9b1fa8b7ae640fa939b7b71bd0704fa9..86711f4c7ddbbf136c0a1a9d0b884f5cd17015dc 100644 (file)
 </summary>
 <seealso><directive module="mod_authz_core">Require</directive></seealso>
 
+<section id="requiredirectives"><title>The Require Directives</title>
+
+    <p>Apache's <directive module="mod_authz_core">Require</directive>
+    directives are used during the authorization phase to ensure that
+    a user is allowed to access a resource.  mod_authz_user extends the
+    authorization types with <code>user</code> and <code>valid-user</code>.
+    </p>
+
+    <p>Since v2.5.0, <a href="../expr.html">expressions</a> are supported
+    within the user require directives.</p>
+
+<section id="requser"><title>Require user</title>
+
+    <p>This directive specifies a list of users that are allowed to gain
+    access.</p>
+
+    <highlight language="config">
+      Require user john paul george ringo
+    </highlight>
+
+</section>
+
+<section id="reqvaliduser"><title>Require valid-user</title>
+
+    <p>When this directive is specified, any successfully authenticated
+    user will be allowed to gain access.</p>
+
+    <highlight language="config">
+      Require valid-user
+    </highlight>
+
+</section>
+
+</section>
+
 </modulesynopsis>
index e4af7946a402bc8d2e37d415515faa335bbb177f..0f45395ed81e7f21444cf4bacb9ec1ac353ba193 100644 (file)
@@ -49,13 +49,25 @@ static authz_status user_check_authorization(request_rec *r,
                                              const char *require_args,
                                              const void *parsed_require_args)
 {
+    const char *err = NULL;
+    const ap_expr_info_t *expr = parsed_require_args;
+    const char *require;
+
     const char *t, *w;
 
     if (!r->user) {
         return AUTHZ_DENIED_NO_USER;
     }
 
-    t = require_args;
+    require = ap_expr_str_exec(r, expr, &err);
+    if (err) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02594)
+                      "authz_user authorize: require user: Can't "
+                      "evaluate require expression: %s", err);
+        return AUTHZ_DENIED;
+    }
+
+    t = require;
     while ((w = ap_getword_conf(r->pool, &t)) && w[0]) {
         if (!strcmp(r->user, w)) {
             return AUTHZ_GRANTED;
@@ -81,10 +93,29 @@ static authz_status validuser_check_authorization(request_rec *r,
     return AUTHZ_GRANTED;
 }
 
+static const char *user_parse_config(cmd_parms *cmd, const char *require_line,
+                                     const void **parsed_require_line)
+{
+    const char *expr_err = NULL;
+    ap_expr_info_t *expr = apr_pcalloc(cmd->pool, sizeof(*expr));
+
+    expr = ap_expr_parse_cmd(cmd, require_line, AP_EXPR_FLAG_STRING_RESULT,
+            &expr_err, NULL);
+
+    if (expr_err)
+        return apr_pstrcat(cmd->temp_pool,
+                           "Cannot parse expression in require line: ",
+                           expr_err, NULL);
+
+    *parsed_require_line = expr;
+
+    return NULL;
+}
+
 static const authz_provider authz_user_provider =
 {
     &user_check_authorization,
-    NULL,
+    &user_parse_config,
 };
 static const authz_provider authz_validuser_provider =
 {