summaryrefslogtreecommitdiffstats
path: root/modules/aaa/mod_authz_host.c
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2010-09-19 20:09:18 +0200
committerStefan Fritsch <sf@apache.org>2010-09-19 20:09:18 +0200
commit39e871f7e476619e9cc9c2559a92c20a880da785 (patch)
treebc8929730696f0becfca48b2577d2e6108648930 /modules/aaa/mod_authz_host.c
parentAllow authz providers to check args while reading the config and allow (diff)
downloadapache2-39e871f7e476619e9cc9c2559a92c20a880da785.tar.xz
apache2-39e871f7e476619e9cc9c2559a92c20a880da785.zip
Add method authz provider as potential Limit/LimitExcept replacement.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@998708 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/aaa/mod_authz_host.c')
-rw-r--r--modules/aaa/mod_authz_host.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/aaa/mod_authz_host.c b/modules/aaa/mod_authz_host.c
index a56d7738c4..b9d99d0afc 100644
--- a/modules/aaa/mod_authz_host.c
+++ b/modules/aaa/mod_authz_host.c
@@ -244,6 +244,38 @@ static const char *all_parse_config(cmd_parms *cmd, const char *require_line,
}
}
+static authz_status method_check_authorization(request_rec *r,
+ const char *require_line,
+ const void *parsed_require_line)
+{
+ const apr_int64_t *allowed = parsed_require_line;
+ if (*allowed & (AP_METHOD_BIT << r->method_number))
+ return AUTHZ_GRANTED;
+ else
+ return AUTHZ_DENIED;
+}
+
+static const char *method_parse_config(cmd_parms *cmd, const char *require_line,
+ const void **parsed_require_line)
+{
+ const char *w, *t;
+ apr_int64_t *allowed = apr_pcalloc(cmd->pool, sizeof(apr_int64_t));
+
+ t = require_line;
+
+ while ((w = ap_getword_conf(cmd->temp_pool, &t)) && w[0]) {
+ int m = ap_method_number_of(w);
+ if (m == M_INVALID) {
+ return apr_pstrcat(cmd->pool, "Invalid Method '", w, "'", NULL);
+ }
+
+ *allowed |= (AP_METHOD_BIT << m);
+ }
+
+ *parsed_require_line = allowed;
+ return NULL;
+}
+
static const authz_provider authz_env_provider =
{
&env_check_authorization,
@@ -268,6 +300,12 @@ static const authz_provider authz_all_provider =
&all_parse_config,
};
+static const authz_provider authz_method_provider =
+{
+ &method_check_authorization,
+ &method_parse_config,
+};
+
static void register_hooks(apr_pool_t *p)
{
ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "env",
@@ -282,6 +320,9 @@ static void register_hooks(apr_pool_t *p)
ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "all",
AUTHZ_PROVIDER_VERSION,
&authz_all_provider, AP_AUTH_INTERNAL_PER_CONF);
+ ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "method",
+ AUTHZ_PROVIDER_VERSION,
+ &authz_method_provider, AP_AUTH_INTERNAL_PER_CONF);
}
AP_DECLARE_MODULE(authz_host) =