842ae4bd224140319ae7feec1872b93dfd491143fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding * contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding * this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding * The ASF licenses this file to You under the Apache License, Version 2.0
842ae4bd224140319ae7feec1872b93dfd491143fielding * (the "License"); you may not use this file except in compliance with
842ae4bd224140319ae7feec1872b93dfd491143fielding * the License. You may obtain a copy of the License at
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * Unless required by applicable law or agreed to in writing, software
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * distributed under the License is distributed on an "AS IS" BASIS,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * See the License for the specific language governing permissions and
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * limitations under the License.
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * Security options etc.
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * Module derived from code originally written by Rob McCool
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdtypedef enum {
4feb1b3dbcb682b0ea5d876f2894b675aed9ad35sf /** true if this is not a real container but produced by AuthMerging;
4feb1b3dbcb682b0ea5d876f2894b675aed9ad35sf * only used for logging */
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdtypedef struct authz_core_dir_conf authz_core_dir_conf;
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdstatic authz_core_dir_conf *authz_core_first_dir_conf;
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholesstatic void *create_authz_core_dir_config(apr_pool_t *p, char *dummy)
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisd authz_core_dir_conf *conf = apr_pcalloc(p, sizeof(*conf));
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes return (void *)conf;
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisdstatic void *merge_authz_core_dir_config(apr_pool_t *p,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes authz_core_dir_conf *base = (authz_core_dir_conf *)basev;
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes authz_core_dir_conf *new = (authz_core_dir_conf *)newv;
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf if (new->op == AUTHZ_LOGIC_UNSET && !new->section && base->section ) {
11e076839c8d5a82d55e710194d0daac51390dbdsf /* Only authz_forbidden_on_fail has been set in new. Don't treat
11e076839c8d5a82d55e710194d0daac51390dbdsf * it as a new auth config w.r.t. AuthMerging */
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf else if (new->op == AUTHZ_LOGIC_OFF || new->op == AUTHZ_LOGIC_UNSET ||
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd section = apr_pmemdup(p, new->section, sizeof(*new->section));
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf conf->authz_forbidden_on_fail = base->authz_forbidden_on_fail;
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf conf->authz_forbidden_on_fail = new->authz_forbidden_on_fail;
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes return (void*)conf;
b47fd7ec6545b9120660f1723f9d5c5624744f4ccovener/* Only per-server directive we have is GLOBAL_ONLY */
b47fd7ec6545b9120660f1723f9d5c5624744f4ccovenerstatic void *merge_authz_core_svr_config(apr_pool_t *p,
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholesstatic void *create_authz_core_svr_config(apr_pool_t *p, server_rec *s)
95b1a32e3398084889f7d948477e02d5a3b9f9cachrisd return (void *)authcfg;
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd/* This is a fake authz provider that really merges various authz alias
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd * configurations and then invokes them.
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisdstatic authz_status authz_alias_check_authorization(request_rec *r,
97cc46935ec496b83fef9d6feb094d706c895b3bsf const char *require_args,
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd /* Look up the provider alias in the alias list.
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd * Get the the dir_config and call ap_Merge_per_dir_configs()
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd * Call the real provider->check_authorization() function
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd * return the result of the above function call
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisd provider_name = apr_table_get(r->notes, AUTHZ_PROVIDER_NAME_NOTE);
36300c97db6e8e2b6ad38cead57f921ad9848106chrisd authcfg = ap_get_module_config(r->server->module_config,
36300c97db6e8e2b6ad38cead57f921ad9848106chrisd prvdraliasrec = apr_hash_get(authcfg->alias_rec, provider_name,
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd /* If we found the alias provider in the list, then merge the directory
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd configurations and call the real provider */
36300c97db6e8e2b6ad38cead57f921ad9848106chrisd ap_conf_vector_t *orig_dir_config = r->per_dir_config;
21da42a6b8f551ef603bd06356d3bf71d6d0c21dsf ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02305)
21da42a6b8f551ef603bd06356d3bf71d6d0c21dsf "no alias provider found for '%s' (BUG?)",
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisdstatic const char *authz_require_alias_section(cmd_parms *cmd, void *mconfig,
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisd const char *args)
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd /* Pull the real provider name and the alias name from the block header */
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisd new_authz_config = ap_create_per_dir_config(cmd->pool);
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd /* Walk the subsection configuration to get the per_dir config that we will
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd * merge just before the real provider is called.
f8ce85be85fcd02385a5a3cb469530f7474c0daechrisd errmsg = ap_walk_config(cmd->directive->first_child, cmd,
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisd prvdraliasrec = apr_pcalloc(cmd->pool, sizeof(*prvdraliasrec));
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd /* Save off the new directory config along with the original
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd * provider name and function pointer data
36300c97db6e8e2b6ad38cead57f921ad9848106chrisd ap_lookup_provider(AUTHZ_PROVIDER_GROUP, provider_name,
9829e274c4f34e23acc7b1bbe1c563049bab5776chrisd /* by the time the config file is used, the provider should be loaded
9829e274c4f34e23acc7b1bbe1c563049bab5776chrisd * and registered with us.
9829e274c4f34e23acc7b1bbe1c563049bab5776chrisd "Unknown Authz provider: %s",
21da42a6b8f551ef603bd06356d3bf71d6d0c21dsf "Can't parse 'Require %s %s': %s",
36300c97db6e8e2b6ad38cead57f921ad9848106chrisd authcfg = ap_get_module_config(cmd->server->module_config,
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd /* Register the fake provider so that we get called first */
cb556b487ce3b50b3b69abadccd3b78b7a5507bdchrisd ap_register_auth_provider(cmd->pool, AUTHZ_PROVIDER_GROUP,
5014faa85f522902d3326b3182d4b389cd520d9echrisdstatic const char* format_authz_result(authz_status result)
5014faa85f522902d3326b3182d4b389cd520d9echrisd ? "granted"
4feb1b3dbcb682b0ea5d876f2894b675aed9ad35sf ? "denied (no authenticated user yet)"
18b5268e013574026b2503b1641baf3299045f45sf : "neutral")));
5014faa85f522902d3326b3182d4b389cd520d9echrisdstatic const char* format_authz_command(apr_pool_t *p,
5014faa85f522902d3326b3182d4b389cd520d9echrisd ? apr_pstrcat(p, "Require ", (section->negate ? "not " : ""),
4feb1b3dbcb682b0ea5d876f2894b675aed9ad35sf : apr_pstrcat(p, section->is_merged ? "AuthMerging " : "<Require",
5014faa85f522902d3326b3182d4b389cd520d9echrisdstatic authz_section_conf* create_default_section(apr_pool_t *p)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd authz_section_conf *section = apr_pcalloc(p, sizeof(*section));
7871f87cd19d007e2cc8efe7480171343efda61abnicholesstatic const char *add_authz_provider(cmd_parms *cmd, void *config,
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisd const char *args)
7871f87cd19d007e2cc8efe7480171343efda61abnicholes authz_core_dir_conf *conf = (authz_core_dir_conf*)config;
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd authz_section_conf *section = apr_pcalloc(cmd->pool, sizeof(*section));
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd section->provider_name = ap_getword_conf(cmd->pool, &args);
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd section->provider_name = ap_getword_conf(cmd->pool, &args);
7871f87cd19d007e2cc8efe7480171343efda61abnicholes /* lookup and cache the actual provider now */
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd section->provider = ap_lookup_provider(AUTHZ_PROVIDER_GROUP,
7871f87cd19d007e2cc8efe7480171343efda61abnicholes /* by the time the config file is used, the provider should be loaded
7871f87cd19d007e2cc8efe7480171343efda61abnicholes * and registered with us.
7871f87cd19d007e2cc8efe7480171343efda61abnicholes "Unknown Authz provider: %s",
7871f87cd19d007e2cc8efe7480171343efda61abnicholes /* if the provider doesn't provide the appropriate function, reject it */
7871f87cd19d007e2cc8efe7480171343efda61abnicholes "The '%s' Authz provider is not supported by any "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "of the loaded authorization modules",
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd if (section->negate && conf->section->op == AUTHZ_LOGIC_OR) {
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd return apr_psprintf(cmd->pool, "negative %s directive has no effect "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "in %s directive",
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisdstatic const char *add_authz_section(cmd_parms *cmd, void *mconfig,
d507f8c93e58b2c65925ef42b70eab268a1cbbfechrisd const char *args)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "> directive doesn't take additional arguments",
5014faa85f522902d3326b3182d4b389cd520d9echrisd else if (!strcasecmp(cmd->cmd->name, "<RequireAny")) {
5014faa85f522902d3326b3182d4b389cd520d9echrisd else if (!strcasecmp(cmd->cmd->name, "<RequireNotAll")) {
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd /* trigger NOT_IN_LIMIT errors as if this were a <Limit> directive */
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd errmsg = ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
5014faa85f522902d3326b3182d4b389cd520d9echrisd old_section = conf->section = create_default_section(cmd->pool);
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd if (section->negate && old_section->op == AUTHZ_LOGIC_OR) {
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "no effect in %s directive",
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd if (!section->negate && section->op == old_section->op) {
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd /* be associative */
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd " directive contains no authorization directives",
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdstatic const char *authz_merge_sections(cmd_parms *cmd, void *mconfig,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd const char *arg)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd return apr_pstrcat(cmd->pool, cmd->cmd->name, " must be one of: "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdstatic int authz_core_check_section(apr_pool_t *p, server_rec *s,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd if (authz_core_check_section(p, s, child, 0) != OK) {
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd /* avoid one level of recursion when De Morgan permits */
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, APR_SUCCESS, s, APLOGNO(01624)
fc251eb7714d158c2952bc2ddbbcfb9169098212sf "%s directive contains only negative authorization directives",
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdstatic int authz_core_pre_config(apr_pool_t *p, apr_pool_t *plog,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdstatic int authz_core_check_config(apr_pool_t *p, apr_pool_t *plog,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd authz_core_dir_conf *conf = authz_core_first_dir_conf;
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd if (authz_core_check_section(p, s, conf->section, 1) != OK) {
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd AP_INIT_RAW_ARGS("<AuthzProviderAlias", authz_require_alias_section,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "container for grouping an authorization provider's "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "directives under a provider alias"),
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd AP_INIT_RAW_ARGS("Require", add_authz_provider, NULL, OR_AUTHCFG,
5014faa85f522902d3326b3182d4b389cd520d9echrisd "specifies authorization directives "
5014faa85f522902d3326b3182d4b389cd520d9echrisd "which one must pass (or not) for a request to suceeed"),
5014faa85f522902d3326b3182d4b389cd520d9echrisd AP_INIT_RAW_ARGS("<RequireAll", add_authz_section, NULL, OR_AUTHCFG,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "container for grouping authorization directives "
221ee9cbaffea40ec8219ee3194f2d711e589229chrisd "of which none must fail and at least one must pass "
221ee9cbaffea40ec8219ee3194f2d711e589229chrisd "for a request to succeed"),
5014faa85f522902d3326b3182d4b389cd520d9echrisd AP_INIT_RAW_ARGS("<RequireAny", add_authz_section, NULL, OR_AUTHCFG,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "container for grouping authorization directives "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "of which one must pass "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "for a request to succeed"),
5014faa85f522902d3326b3182d4b389cd520d9echrisd AP_INIT_RAW_ARGS("<RequireNotAll", add_authz_section, NULL, OR_AUTHCFG,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "container for grouping authorization directives "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "of which some must fail or none must pass "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "for a request to succeed"),
5014faa85f522902d3326b3182d4b389cd520d9echrisd AP_INIT_RAW_ARGS("<RequireNone", add_authz_section, NULL, OR_AUTHCFG,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "container for grouping authorization directives "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "of which none must pass "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "for a request to succeed"),
5014faa85f522902d3326b3182d4b389cd520d9echrisd AP_INIT_TAKE1("AuthMerging", authz_merge_sections, NULL, OR_AUTHCFG,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "controls how a <Directory>, <Location>, or similar "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "directive's authorization directives are combined with "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "those of its predecessor"),
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf AP_INIT_FLAG("AuthzSendForbiddenOnFailure", ap_set_flag_slot_char,
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf (void *)APR_OFFSETOF(authz_core_dir_conf, authz_forbidden_on_fail),
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf "Controls if an authorization failure should result in a "
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf "'403 FORBIDDEN' response instead of the HTTP-conforming "
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf "'401 UNAUTHORIZED'"),
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisdstatic authz_status apply_authz_sections(request_rec *r,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd /* check to make sure that the request method requires authorization */
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd if (!(section->limited & (AP_METHOD_BIT << r->method_number))) {
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd (parent_op == AUTHZ_LOGIC_AND) ? AUTHZ_GRANTED : AUTHZ_NEUTRAL;
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, APLOGNO(01625)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "authorization result of %s: %s "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "(directive limited to other methods)",
97cc46935ec496b83fef9d6feb094d706c895b3bsf section->provider->check_authorization(r, section->provider_args,
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd child_result = apply_authz_sections(r, child, section->op);
18b5268e013574026b2503b1641baf3299045f45sf * Handling of AUTHZ_DENIED/AUTHZ_DENIED_NO_USER: Return
18b5268e013574026b2503b1641baf3299045f45sf * AUTHZ_DENIED_NO_USER if providing a user may change the
18b5268e013574026b2503b1641baf3299045f45sf * result, AUTHZ_DENIED otherwise.
dd9f60fdfeb73f829fe0b260b7975b4b22be0838sf /* AUTHZ_LOGIC_OR */
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd /* For negated directives, if the original result was denied
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd * then the new result is neutral since we can not grant
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd * access simply because authorization was not rejected.
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, APLOGNO(01626)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "authorization result of %s: %s",
18b5268e013574026b2503b1641baf3299045f45sfstatic int authorize_user_core(request_rec *r, int after_authn)
5692bc05d2e606215730568e47bba1b9beabef99chrisd conf = ap_get_module_config(r->per_dir_config, &authz_core_module);
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd /* there's an AuthType configured, but no authorization
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd * directives applied to support it
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, APLOGNO(01627)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "AuthType configured with no corresponding "
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "authorization directives");
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, APLOGNO(01628)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "authorization result: granted (no directives)");
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd auth_result = apply_authz_sections(r, conf->section, AUTHZ_LOGIC_AND);
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, APLOGNO(01629)
18b5268e013574026b2503b1641baf3299045f45sf "authorization failure (no authenticated user): %s",
18b5268e013574026b2503b1641baf3299045f45sf * If we're returning 401 to an authenticated user, tell them to
18b5268e013574026b2503b1641baf3299045f45sf * try again. If unauthenticated, note_auth_failure has already
18b5268e013574026b2503b1641baf3299045f45sf * been called during auth.
18b5268e013574026b2503b1641baf3299045f45sf * We need a user before we can decide what to do.
18b5268e013574026b2503b1641baf3299045f45sf * Get out of the way and proceed with authentication.
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd else if (auth_result == AUTHZ_DENIED || auth_result == AUTHZ_NEUTRAL) {
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, APLOGNO(01630)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "client denied by server configuration: %s%s",
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, APLOGNO(01631)
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd "user %s: authorization failure for \"%s\": ",
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf * If we're returning 401 to an authenticated user, tell them to
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf * try again. If unauthenticated, note_auth_failure has already
5bbabc874e3fcfbea08c199f7a79ee05b4817a70sf * been called during auth.
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd /* We'll assume that the module has already said what its
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd * error was in the logs.
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholesstatic int authz_some_auth_required(request_rec *r)
5692bc05d2e606215730568e47bba1b9beabef99chrisd conf = ap_get_module_config(r->per_dir_config, &authz_core_module);
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd && (conf->section->limited & (AP_METHOD_BIT << r->method_number))) {
05b30ac536cfc100ad693b417efc3da2bfae546csf * env authz provider
05b30ac536cfc100ad693b417efc3da2bfae546csfstatic authz_status env_check_authorization(request_rec *r,
05b30ac536cfc100ad693b417efc3da2bfae546csf const char *require_line,
05b30ac536cfc100ad693b417efc3da2bfae546csf const char *t, *w;
05b30ac536cfc100ad693b417efc3da2bfae546csf /* The 'env' provider will allow the configuration to specify a list of
05b30ac536cfc100ad693b417efc3da2bfae546csf env variables to check rather than a single variable. This is different
05b30ac536cfc100ad693b417efc3da2bfae546csf from the previous host based syntax. */
05b30ac536cfc100ad693b417efc3da2bfae546csf * all authz provider
05b30ac536cfc100ad693b417efc3da2bfae546csfstatic authz_status all_check_authorization(request_rec *r,
05b30ac536cfc100ad693b417efc3da2bfae546csf const char *require_line,
05b30ac536cfc100ad693b417efc3da2bfae546csfstatic const char *all_parse_config(cmd_parms *cmd, const char *require_line,
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim * If the argument to the 'all' provider is 'granted' then just let
05b30ac536cfc100ad693b417efc3da2bfae546csf * everybody in. This would be equivalent to the previous syntax of
05b30ac536cfc100ad693b417efc3da2bfae546csf * 'allow from all'. If the argument is 'denied' we reject everbody,
05b30ac536cfc100ad693b417efc3da2bfae546csf * which is equivalent to 'deny from all'.
05b30ac536cfc100ad693b417efc3da2bfae546csf /* *parsed_require_line is already NULL */
05b30ac536cfc100ad693b417efc3da2bfae546csf return "Argument for 'Require all' must be 'granted' or 'denied'";
05b30ac536cfc100ad693b417efc3da2bfae546csf * method authz provider
05b30ac536cfc100ad693b417efc3da2bfae546csfstatic authz_status method_check_authorization(request_rec *r,
05b30ac536cfc100ad693b417efc3da2bfae546csf const char *require_line,
05b30ac536cfc100ad693b417efc3da2bfae546csfstatic const char *method_parse_config(cmd_parms *cmd, const char *require_line,
05b30ac536cfc100ad693b417efc3da2bfae546csf const char *w, *t;
05b30ac536cfc100ad693b417efc3da2bfae546csf apr_int64_t *allowed = apr_pcalloc(cmd->pool, sizeof(apr_int64_t));
05b30ac536cfc100ad693b417efc3da2bfae546csf while ((w = ap_getword_conf(cmd->temp_pool, &t)) && w[0]) {
05b30ac536cfc100ad693b417efc3da2bfae546csf if (m == M_INVALID) {
05b30ac536cfc100ad693b417efc3da2bfae546csf return apr_pstrcat(cmd->pool, "Invalid Method '", w, "'", NULL);
4c21a9f062e187b87c9cec726023f0fc086008f2sf * expr authz provider
4c21a9f062e187b87c9cec726023f0fc086008f2sf apr_pool_userdata_get((void**)&info, REQUIRE_EXPR_NOTE, parms->ptemp);
4c21a9f062e187b87c9cec726023f0fc086008f2sfstatic const char *expr_parse_config(cmd_parms *cmd, const char *require_line,
4c21a9f062e187b87c9cec726023f0fc086008f2sf struct require_expr_info *info = apr_pcalloc(cmd->pool, sizeof(*info));
b9eb3442f3eef36ef7232fd107ba1890d94e3352breser /* if the expression happens to be surrounded by quotes, skip them */
4c21a9f062e187b87c9cec726023f0fc086008f2sf apr_pool_userdata_setn(info, REQUIRE_EXPR_NOTE, apr_pool_cleanup_null,
4c21a9f062e187b87c9cec726023f0fc086008f2sf info->expr = ap_expr_parse_cmd(cmd, require_line, 0, &expr_err,
09833366b4d9b23dcd680676820c227a7cb470c9sf "Cannot parse expression in require line: ",
feaca656b298a47325760932c0fbc74600550bcdsfstatic authz_status expr_check_authorization(request_rec *r,
feaca656b298a47325760932c0fbc74600550bcdsf const char *require_line,
4c21a9f062e187b87c9cec726023f0fc086008f2sf const struct require_expr_info *info = parsed_require_line;
81190529a026a31d7d7a707616f20620d3c3673bsf if (rc < 0) {
81190529a026a31d7d7a707616f20620d3c3673bsf ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02320)
81190529a026a31d7d7a707616f20620d3c3673bsf "Error evaluating expression in 'Require expr': %s",
81190529a026a31d7d7a707616f20620d3c3673bsf else if (rc == 0) {
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes APR_REGISTER_OPTIONAL_FN(authz_some_auth_required);
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd ap_hook_pre_config(authz_core_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd ap_hook_check_config(authz_core_check_config, NULL, NULL, APR_HOOK_MIDDLE);
809ec9d7cc8bc12d7dc6fafba24f3acad3e49d81chrisd ap_hook_check_authz(authorize_user, NULL, NULL, APR_HOOK_LAST,
18b5268e013574026b2503b1641baf3299045f45sf ap_hook_check_access_ex(authorize_userless, NULL, NULL, APR_HOOK_LAST,
05b30ac536cfc100ad693b417efc3da2bfae546csf ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "env",
05b30ac536cfc100ad693b417efc3da2bfae546csf ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "all",
05b30ac536cfc100ad693b417efc3da2bfae546csf ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "method",
feaca656b298a47325760932c0fbc74600550bcdsf ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "expr",
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes create_authz_core_dir_config, /* dir config creater */
b47fd7ec6545b9120660f1723f9d5c5624744f4ccovener merge_authz_core_svr_config , /* merge server config */