Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3DAA21004D for ; Sun, 5 Jan 2014 16:10:45 +0000 (UTC) Received: (qmail 52145 invoked by uid 500); 5 Jan 2014 16:10:37 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 52073 invoked by uid 500); 5 Jan 2014 16:10:36 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 52065 invoked by uid 99); 5 Jan 2014 16:10:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jan 2014 16:10:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jan 2014 16:10:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6151C2388868; Sun, 5 Jan 2014 16:10:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1555540 - in /httpd/httpd/branches/2.4.x: ./ CHANGES STATUS docs/manual/ docs/manual/expr.xml docs/manual/mod/ docs/manual/mod/mod_authz_dbd.xml modules/aaa/mod_authz_dbd.c Date: Sun, 05 Jan 2014 16:10:10 -0000 To: cvs@httpd.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140105161010.6151C2388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jim Date: Sun Jan 5 16:10:09 2014 New Revision: 1555540 URL: http://svn.apache.org/r1555540 Log: Merge r1554168, r1554176 from trunk: mod_authnz_dbd: Support the expression parser within the require directives. Pass the correct pointer that made it past the test suite. Submitted by: minfrin Reviewed/backported by: jim Modified: httpd/httpd/branches/2.4.x/ (props changed) httpd/httpd/branches/2.4.x/CHANGES httpd/httpd/branches/2.4.x/STATUS httpd/httpd/branches/2.4.x/docs/manual/ (props changed) httpd/httpd/branches/2.4.x/docs/manual/expr.xml httpd/httpd/branches/2.4.x/docs/manual/mod/ (props changed) httpd/httpd/branches/2.4.x/docs/manual/mod/mod_authz_dbd.xml httpd/httpd/branches/2.4.x/modules/aaa/mod_authz_dbd.c Propchange: httpd/httpd/branches/2.4.x/ ------------------------------------------------------------------------------ Merged /httpd/httpd/trunk:r1554168,1554176 Modified: httpd/httpd/branches/2.4.x/CHANGES URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1555540&r1=1555539&r2=1555540&view=diff ============================================================================== --- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original) +++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Sun Jan 5 16:10:09 2014 @@ -2,6 +2,9 @@ Changes with Apache 2.4.8 + *) mod_authnz_dbd: Support the expression parser within the require + directives. [Graham Leggett] + *) mod_authnz_ldap: Support the expression parser within the require directives. [Graham Leggett] Modified: httpd/httpd/branches/2.4.x/STATUS URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1555540&r1=1555539&r2=1555540&view=diff ============================================================================== --- httpd/httpd/branches/2.4.x/STATUS (original) +++ httpd/httpd/branches/2.4.x/STATUS Sun Jan 5 16:10:09 2014 @@ -98,12 +98,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_authz_dbd: Support the expression parser within the require directives. - trunk patch: http://svn.apache.org/r1554168 - http://svn.apache.org/r1554176 - 2.4.x patch: trunk works (modulo CHANGES and log-message-tags) - +1: minfrin, jim, covener - * mod_authz_dbm: Support the expression parser within the require directives. trunk patch: http://svn.apache.org/r1554170 http://svn.apache.org/r1554181 Propchange: httpd/httpd/branches/2.4.x/docs/manual/ ------------------------------------------------------------------------------ Merged /httpd/httpd/trunk/docs/manual:r1554168 Modified: httpd/httpd/branches/2.4.x/docs/manual/expr.xml URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/expr.xml?rev=1555540&r1=1555539&r2=1555540&view=diff ============================================================================== --- httpd/httpd/branches/2.4.x/docs/manual/expr.xml (original) +++ httpd/httpd/branches/2.4.x/docs/manual/expr.xml Sun Jan 5 16:10:09 2014 @@ -56,6 +56,7 @@ Require ldap-dn Require ldap-attribute Require ldap-filter +Require dbd-group SSLRequire LogMessage mod_include Propchange: httpd/httpd/branches/2.4.x/docs/manual/mod/ ------------------------------------------------------------------------------ Merged /httpd/httpd/trunk/docs/manual/mod:r1554168 Modified: httpd/httpd/branches/2.4.x/docs/manual/mod/mod_authz_dbd.xml URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/mod/mod_authz_dbd.xml?rev=1555540&r1=1555539&r2=1555540&view=diff ============================================================================== --- httpd/httpd/branches/2.4.x/docs/manual/mod/mod_authz_dbd.xml (original) +++ httpd/httpd/branches/2.4.x/docs/manual/mod/mod_authz_dbd.xml Sun Jan 5 16:10:09 2014 @@ -52,6 +52,55 @@ DBDriver DBDParams +
The Require Directives + +

Apache's Require + directives are used during the authorization phase to ensure that + a user is allowed to access a resource. mod_authz_dbd extends the + authorization types with dbd-group, dbd-login and + dbd-logout.

+ +

Since v2.5.0, expressions are supported + within the DBD require directives.

+ +
Require dbd-group + +

This directive specifies group membership that is required for the + user to gain access.

+ + + Require dbd-group team + AuthzDBDQuery "SELECT group FROM authz WHERE user = %s" + + +
+ +
Require dbd-login + +

This directive specifies a query to be run indicating the user + has logged in.

+ + + Require dbd-login + AuthzDBDQuery "UPDATE authn SET login = 'true' WHERE user = %s" + + +
+ +
Require dbd-logout + +

This directive specifies a query to be run indicating the user + has logged out.

+ + + Require dbd-logout + AuthzDBDQuery "UPDATE authn SET login = 'false' WHERE user = %s" + + +
+ +
+
Database Login

Modified: httpd/httpd/branches/2.4.x/modules/aaa/mod_authz_dbd.c URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/aaa/mod_authz_dbd.c?rev=1555540&r1=1555539&r2=1555540&view=diff ============================================================================== --- httpd/httpd/branches/2.4.x/modules/aaa/mod_authz_dbd.c (original) +++ httpd/httpd/branches/2.4.x/modules/aaa/mod_authz_dbd.c Sun Jan 5 16:10:09 2014 @@ -253,6 +253,11 @@ static authz_status dbdgroup_check_autho int i, rv; const char *w; apr_array_header_t *groups = NULL; + + const char *err = NULL; + const ap_expr_info_t *expr = parsed_require_args; + const char *require; + const char *t; authz_dbd_cfg *cfg = ap_get_module_config(r->per_dir_config, &authz_dbd_module); @@ -269,7 +274,15 @@ static authz_status dbdgroup_check_autho } } - t = require_args; + require = ap_expr_str_exec(r, expr, &err); + if (err) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02590) + "authz_dbd authorize: require dbd-group: Can't " + "evaluate require expression: %s", err); + return AUTHZ_DENIED; + } + + t = require; while (t[0]) { w = ap_getword_white(r->pool, &t); for (i=0; i < groups->nelts; ++i) { @@ -310,10 +323,29 @@ static authz_status dbdlogout_check_auth return (authz_dbd_login(r, cfg, "logout") == OK ? AUTHZ_GRANTED : AUTHZ_DENIED); } +static const char *dbd_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_dbdgroup_provider = { &dbdgroup_check_authorization, - NULL, + &dbd_parse_config, }; static const authz_provider authz_dbdlogin_provider =