From 4a30f52bb68ed053eeb1bb95bb93369b8b53494c Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sun, 10 Jan 2016 09:13:41 +0100 Subject: module: Add support for apache 2.4.x --- module/mod_auth_singleid.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/module/mod_auth_singleid.c b/module/mod_auth_singleid.c index a16961c..5c06c50 100644 --- a/module/mod_auth_singleid.c +++ b/module/mod_auth_singleid.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -1290,6 +1291,55 @@ hook_handler (request_rec *r) return DECLINED; } +#if AP_MODULE_MAGIC_AT_LEAST(20080403,1) + +static authz_status +hook_user (request_rec *r, const char *require_args, + const void *parsed_require_args) +{ + const char *w; + + if (!r->user) + return AUTHZ_DENIED_NO_USER; + + while ((w = ap_getword_conf (r->pool, &require_args)) && w[0]) { + if (strcmp (w, r->user) == 0) + return AUTHZ_GRANTED; + } + + ap_log_rerror (APLOG_MARK, APLOG_ERR, 0, r, + "access to %s failed, reason: user '%s' does not meet access requriements", + r->uri, r->user); + + return AUTHZ_DENIED; +} + +static authz_status +hook_validuser (request_rec *r, const char *require_line, + const void *parsed_require_line) +{ + return r->user ? AUTHZ_GRANTED : AUTHZ_DENIED_NO_USER; +} + +static void +register_hooks(apr_pool_t *p) +{ + static const authz_provider provider_user = { hook_user, NULL, }; + static const authz_provider provider_validuser = { hook_validuser, NULL, }; + + ap_hook_post_config (hook_initialize, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_handler (hook_handler, NULL, NULL, APR_HOOK_FIRST); + ap_hook_child_init (hook_child, NULL, NULL, APR_HOOK_MIDDLE); + + ap_hook_check_authn (hook_authenticate, NULL, NULL, APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF); + ap_register_auth_provider (p, AUTHZ_PROVIDER_GROUP, "valid-user", AUTHZ_PROVIDER_VERSION, + &provider_validuser, AP_AUTH_INTERNAL_PER_CONF); + ap_register_auth_provider (p, AUTHZ_PROVIDER_GROUP, "user", AUTHZ_PROVIDER_VERSION, + &provider_user, AP_AUTH_INTERNAL_PER_CONF); +} + +#else /* Old style Requires stuff */ + static int hook_access(request_rec *r) { @@ -1357,6 +1407,8 @@ register_hooks(apr_pool_t *p) ap_hook_auth_checker (hook_access, NULL, NULL, APR_HOOK_MIDDLE); } +#endif + module AP_MODULE_DECLARE_DATA auth_singleid_module = { STANDARD20_MODULE_STUFF, dir_config_creator, /* dir config creater */ -- cgit v1.2.3