diff options
author | Stef Walter <stefw@redhat.com> | 2016-01-10 09:13:41 +0100 |
---|---|---|
committer | Stef Walter <stefw@redhat.com> | 2016-01-10 09:13:41 +0100 |
commit | 4a30f52bb68ed053eeb1bb95bb93369b8b53494c (patch) | |
tree | 87ebf766c3b6d4a8a09873f929b89380b7b57d71 | |
parent | e596923c690246d15a793d9eb360f6a44d1afa78 (diff) |
module: Add support for apache 2.4.xapache-24
-rw-r--r-- | module/mod_auth_singleid.c | 52 |
1 files changed, 52 insertions, 0 deletions
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 <http_request.h> #include <ap_mpm.h> #include <mod_ssl.h> +#include <mod_auth.h> #include <apr_base64.h> #include <apr_file_io.h> @@ -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 */ |