|
|
00df7d |
diff --git a/docs/manual/expr.html.en b/docs/manual/expr.html.en
|
|
|
00df7d |
index 5c3ae45..8bd941a 100644
|
|
|
00df7d |
--- a/docs/manual/expr.html.en
|
|
|
00df7d |
+++ b/docs/manual/expr.html.en
|
|
|
00df7d |
@@ -46,7 +46,7 @@
|
|
|
00df7d |
Other
|
|
|
00df7d |
Comparison with SSLRequire
|
|
|
00df7d |
Version History
|
|
|
00df7d |
-See also
|
|
|
00df7d |
+See also
|
|
|
00df7d |
|
|
|
00df7d |
|
|
|
00df7d |
|
|
|
00df7d |
diff --git a/docs/manual/mod/mod_authnz_ldap.html.en b/docs/manual/mod/mod_authnz_ldap.html.en
|
|
|
00df7d |
index 7199052..c86dc8a 100644
|
|
|
00df7d |
--- a/docs/manual/mod/mod_authnz_ldap.html.en
|
|
|
00df7d |
+++ b/docs/manual/mod/mod_authnz_ldap.html.en
|
|
|
00df7d |
@@ -350,6 +350,9 @@ for HTTP Basic authentication.
|
|
|
00df7d |
ldap-filter . Other authorization types may also be
|
|
|
00df7d |
used but may require that additional authorization modules be loaded.
|
|
|
00df7d |
|
|
|
00df7d |
+ Since v2.5.0, expressions are supported
|
|
|
00df7d |
+ within the LDAP require directives.
|
|
|
00df7d |
+
|
|
|
00df7d |
|
|
|
00df7d |
|
|
|
00df7d |
The Require ldap-user directive specifies what
|
|
|
00df7d |
@@ -576,6 +579,16 @@ Require ldap-group cn=Administrators, o=Example
|
|
|
00df7d |
|
|
|
00df7d |
|
|
|
00df7d |
|
|
|
00df7d |
+ Grant access to anybody in the group whose name matches the
|
|
|
00df7d |
+ hostname of the virtual host. In this example an
|
|
|
00df7d |
+ expression is used to build the filter.
|
|
|
00df7d |
+<highlight language="config">
|
|
|
00df7d |
+AuthLDAPURL ldap://ldap.example.com/o=Example?uid
|
|
|
00df7d |
+Require ldap-group cn=%{SERVER_NAME}, o=Example
|
|
|
00df7d |
+</highlight>
|
|
|
00df7d |
+
|
|
|
00df7d |
+
|
|
|
00df7d |
+
|
|
|
00df7d |
The next example assumes that everyone at Example who
|
|
|
00df7d |
carries an alphanumeric pager will have an LDAP attribute
|
|
|
00df7d |
of qpagePagerID . The example will grant access
|
|
|
00df7d |
diff --git a/modules/aaa/mod_authnz_ldap.c b/modules/aaa/mod_authnz_ldap.c
|
|
|
00df7d |
index 2c25dbc..063debe 100644
|
|
|
00df7d |
--- a/modules/aaa/mod_authnz_ldap.c
|
|
|
00df7d |
+++ b/modules/aaa/mod_authnz_ldap.c
|
|
|
00df7d |
@@ -607,6 +607,10 @@ static authz_status ldapuser_check_authorization(request_rec *r,
|
|
|
00df7d |
|
|
|
00df7d |
util_ldap_connection_t *ldc = NULL;
|
|
|
00df7d |
|
|
|
00df7d |
+ const char *err = NULL;
|
|
|
00df7d |
+ const ap_expr_info_t *expr = parsed_require_args;
|
|
|
00df7d |
+ const char *require;
|
|
|
00df7d |
+
|
|
|
00df7d |
const char *t;
|
|
|
00df7d |
char *w;
|
|
|
00df7d |
|
|
|
00df7d |
@@ -680,11 +684,19 @@ static authz_status ldapuser_check_authorization(request_rec *r,
|
|
|
00df7d |
return AUTHZ_DENIED;
|
|
|
00df7d |
}
|
|
|
00df7d |
|
|
|
00df7d |
+ require = ap_expr_str_exec(r, expr, &err;;
|
|
|
00df7d |
+ if (err) {
|
|
|
00df7d |
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02585)
|
|
|
00df7d |
+ "auth_ldap authorize: require user: Can't evaluate expression: %s",
|
|
|
00df7d |
+ err);
|
|
|
00df7d |
+ return AUTHZ_DENIED;
|
|
|
00df7d |
+ }
|
|
|
00df7d |
+
|
|
|
00df7d |
/*
|
|
|
00df7d |
* First do a whole-line compare, in case it's something like
|
|
|
00df7d |
* require user Babs Jensen
|
|
|
00df7d |
*/
|
|
|
00df7d |
- result = util_ldap_cache_compare(r, ldc, sec->url, req->dn, sec->attribute, require_args);
|
|
|
00df7d |
+ result = util_ldap_cache_compare(r, ldc, sec->url, req->dn, sec->attribute, require);
|
|
|
00df7d |
switch(result) {
|
|
|
00df7d |
case LDAP_COMPARE_TRUE: {
|
|
|
00df7d |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01703)
|
|
|
00df7d |
@@ -704,7 +716,7 @@ static authz_status ldapuser_check_authorization(request_rec *r,
|
|
|
00df7d |
/*
|
|
|
00df7d |
* Now break apart the line and compare each word on it
|
|
|
00df7d |
*/
|
|
|
00df7d |
- t = require_args;
|
|
|
00df7d |
+ t = require;
|
|
|
00df7d |
while ((w = ap_getword_conf(r->pool, &t)) && w[0]) {
|
|
|
00df7d |
result = util_ldap_cache_compare(r, ldc, sec->url, req->dn, sec->attribute, w);
|
|
|
00df7d |
switch(result) {
|
|
|
00df7d |
@@ -744,6 +756,10 @@ static authz_status ldapgroup_check_authorization(request_rec *r,
|
|
|
00df7d |
|
|
|
00df7d |
util_ldap_connection_t *ldc = NULL;
|
|
|
00df7d |
|
|
|
00df7d |
+ const char *err = NULL;
|
|
|
00df7d |
+ const ap_expr_info_t *expr = parsed_require_args;
|
|
|
00df7d |
+ const char *require;
|
|
|
00df7d |
+
|
|
|
00df7d |
const char *t;
|
|
|
00df7d |
|
|
|
00df7d |
char filtbuf[FILTER_LENGTH];
|
|
|
00df7d |
@@ -863,7 +879,15 @@ static authz_status ldapgroup_check_authorization(request_rec *r,
|
|
|
00df7d |
}
|
|
|
00df7d |
}
|
|
|
00df7d |
|
|
|
00df7d |
- t = require_args;
|
|
|
00df7d |
+ require = ap_expr_str_exec(r, expr, &err;;
|
|
|
00df7d |
+ if (err) {
|
|
|
00df7d |
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02586)
|
|
|
00df7d |
+ "auth_ldap authorize: require group: Can't evaluate expression: %s",
|
|
|
00df7d |
+ err);
|
|
|
00df7d |
+ return AUTHZ_DENIED;
|
|
|
00df7d |
+ }
|
|
|
00df7d |
+
|
|
|
00df7d |
+ t = require;
|
|
|
00df7d |
|
|
|
00df7d |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01713)
|
|
|
00df7d |
"auth_ldap authorize: require group: testing for group "
|
|
|
00df7d |
@@ -959,6 +983,10 @@ static authz_status ldapdn_check_authorization(request_rec *r,
|
|
|
00df7d |
|
|
|
00df7d |
util_ldap_connection_t *ldc = NULL;
|
|
|
00df7d |
|
|
|
00df7d |
+ const char *err = NULL;
|
|
|
00df7d |
+ const ap_expr_info_t *expr = parsed_require_args;
|
|
|
00df7d |
+ const char *require;
|
|
|
00df7d |
+
|
|
|
00df7d |
const char *t;
|
|
|
00df7d |
|
|
|
00df7d |
char filtbuf[FILTER_LENGTH];
|
|
|
00df7d |
@@ -1021,7 +1049,15 @@ static authz_status ldapdn_check_authorization(request_rec *r,
|
|
|
00df7d |
req->user = r->user;
|
|
|
00df7d |
}
|
|
|
00df7d |
|
|
|
00df7d |
- t = require_args;
|
|
|
00df7d |
+ require = ap_expr_str_exec(r, expr, &err;;
|
|
|
00df7d |
+ if (err) {
|
|
|
00df7d |
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02587)
|
|
|
00df7d |
+ "auth_ldap authorize: require dn: Can't evaluate expression: %s",
|
|
|
00df7d |
+ err);
|
|
|
00df7d |
+ return AUTHZ_DENIED;
|
|
|
00df7d |
+ }
|
|
|
00df7d |
+
|
|
|
00df7d |
+ t = require;
|
|
|
00df7d |
|
|
|
00df7d |
if (req->dn == NULL || strlen(req->dn) == 0) {
|
|
|
00df7d |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01725)
|
|
|
00df7d |
@@ -1068,6 +1104,10 @@ static authz_status ldapattribute_check_authorization(request_rec *r,
|
|
|
00df7d |
|
|
|
00df7d |
util_ldap_connection_t *ldc = NULL;
|
|
|
00df7d |
|
|
|
00df7d |
+ const char *err = NULL;
|
|
|
00df7d |
+ const ap_expr_info_t *expr = parsed_require_args;
|
|
|
00df7d |
+ const char *require;
|
|
|
00df7d |
+
|
|
|
00df7d |
const char *t;
|
|
|
00df7d |
char *w, *value;
|
|
|
00df7d |
|
|
|
00df7d |
@@ -1138,7 +1178,16 @@ static authz_status ldapattribute_check_authorization(request_rec *r,
|
|
|
00df7d |
return AUTHZ_DENIED;
|
|
|
00df7d |
}
|
|
|
00df7d |
|
|
|
00df7d |
- t = require_args;
|
|
|
00df7d |
+ require = ap_expr_str_exec(r, expr, &err;;
|
|
|
00df7d |
+ if (err) {
|
|
|
00df7d |
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02588)
|
|
|
00df7d |
+ "auth_ldap authorize: require ldap-attribute: Can't "
|
|
|
00df7d |
+ "evaluate expression: %s", err);
|
|
|
00df7d |
+ return AUTHZ_DENIED;
|
|
|
00df7d |
+ }
|
|
|
00df7d |
+
|
|
|
00df7d |
+ t = require;
|
|
|
00df7d |
+
|
|
|
00df7d |
while (t[0]) {
|
|
|
00df7d |
w = ap_getword(r->pool, &t, '=');
|
|
|
00df7d |
value = ap_getword_conf(r->pool, &t);
|
|
|
00df7d |
@@ -1183,6 +1232,11 @@ static authz_status ldapfilter_check_authorization(request_rec *r,
|
|
|
00df7d |
(authn_ldap_config_t *)ap_get_module_config(r->per_dir_config, &authnz_ldap_module);
|
|
|
00df7d |
|
|
|
00df7d |
util_ldap_connection_t *ldc = NULL;
|
|
|
00df7d |
+
|
|
|
00df7d |
+ const char *err = NULL;
|
|
|
00df7d |
+ const ap_expr_info_t *expr = parsed_require_args;
|
|
|
00df7d |
+ const char *require;
|
|
|
00df7d |
+
|
|
|
00df7d |
const char *t;
|
|
|
00df7d |
|
|
|
00df7d |
char filtbuf[FILTER_LENGTH];
|
|
|
00df7d |
@@ -1252,7 +1306,15 @@ static authz_status ldapfilter_check_authorization(request_rec *r,
|
|
|
00df7d |
return AUTHZ_DENIED;
|
|
|
00df7d |
}
|
|
|
00df7d |
|
|
|
00df7d |
- t = require_args;
|
|
|
00df7d |
+ require = ap_expr_str_exec(r, expr, &err;;
|
|
|
00df7d |
+ if (err) {
|
|
|
00df7d |
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02589)
|
|
|
00df7d |
+ "auth_ldap authorize: require ldap-filter: Can't "
|
|
|
00df7d |
+ "evaluate require expression: %s", err);
|
|
|
00df7d |
+ return AUTHZ_DENIED;
|
|
|
00df7d |
+ }
|
|
|
00df7d |
+
|
|
|
00df7d |
+ t = require;
|
|
|
00df7d |
|
|
|
00df7d |
if (t[0]) {
|
|
|
00df7d |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01743)
|
|
|
00df7d |
@@ -1311,6 +1373,25 @@ static authz_status ldapfilter_check_authorization(request_rec *r,
|
|
|
00df7d |
return AUTHZ_DENIED;
|
|
|
00df7d |
}
|
|
|
00df7d |
|
|
|
00df7d |
+static const char *ldap_parse_config(cmd_parms *cmd, const char *require_line,
|
|
|
00df7d |
+ const void **parsed_require_line)
|
|
|
00df7d |
+{
|
|
|
00df7d |
+ const char *expr_err = NULL;
|
|
|
00df7d |
+ ap_expr_info_t *expr;
|
|
|
00df7d |
+
|
|
|
00df7d |
+ expr = ap_expr_parse_cmd(cmd, require_line, AP_EXPR_FLAG_STRING_RESULT,
|
|
|
00df7d |
+ &expr_err, NULL);
|
|
|
00df7d |
+
|
|
|
00df7d |
+ if (expr_err)
|
|
|
00df7d |
+ return apr_pstrcat(cmd->temp_pool,
|
|
|
00df7d |
+ "Cannot parse expression in require line: ",
|
|
|
00df7d |
+ expr_err, NULL);
|
|
|
00df7d |
+
|
|
|
00df7d |
+ *parsed_require_line = expr;
|
|
|
00df7d |
+
|
|
|
00df7d |
+ return NULL;
|
|
|
00df7d |
+}
|
|
|
00df7d |
+
|
|
|
00df7d |
|
|
|
00df7d |
/*
|
|
|
00df7d |
* Use the ldap url parsing routines to break up the ldap url into
|
|
|
00df7d |
@@ -1769,30 +1850,30 @@ static const authn_provider authn_ldap_provider =
|
|
|
00df7d |
static const authz_provider authz_ldapuser_provider =
|
|
|
00df7d |
{
|
|
|
00df7d |
&ldapuser_check_authorization,
|
|
|
00df7d |
- NULL,
|
|
|
00df7d |
+ &ldap_parse_config,
|
|
|
00df7d |
};
|
|
|
00df7d |
static const authz_provider authz_ldapgroup_provider =
|
|
|
00df7d |
{
|
|
|
00df7d |
&ldapgroup_check_authorization,
|
|
|
00df7d |
- NULL,
|
|
|
00df7d |
+ &ldap_parse_config,
|
|
|
00df7d |
};
|
|
|
00df7d |
|
|
|
00df7d |
static const authz_provider authz_ldapdn_provider =
|
|
|
00df7d |
{
|
|
|
00df7d |
&ldapdn_check_authorization,
|
|
|
00df7d |
- NULL,
|
|
|
00df7d |
+ &ldap_parse_config,
|
|
|
00df7d |
};
|
|
|
00df7d |
|
|
|
00df7d |
static const authz_provider authz_ldapattribute_provider =
|
|
|
00df7d |
{
|
|
|
00df7d |
&ldapattribute_check_authorization,
|
|
|
00df7d |
- NULL,
|
|
|
00df7d |
+ &ldap_parse_config,
|
|
|
00df7d |
};
|
|
|
00df7d |
|
|
|
00df7d |
static const authz_provider authz_ldapfilter_provider =
|
|
|
00df7d |
{
|
|
|
00df7d |
&ldapfilter_check_authorization,
|
|
|
00df7d |
- NULL,
|
|
|
00df7d |
+ &ldap_parse_config,
|
|
|
00df7d |
};
|
|
|
00df7d |
|
|
|
00df7d |
static void ImportULDAPOptFn(void)
|