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