135c1278adef96d36fd421c536b1acc54a341cfbsf/* Licensed to the Apache Software Foundation (ASF) under one or more
135c1278adef96d36fd421c536b1acc54a341cfbsf * contributor license agreements. See the NOTICE file distributed with
135c1278adef96d36fd421c536b1acc54a341cfbsf * this work for additional information regarding copyright ownership.
135c1278adef96d36fd421c536b1acc54a341cfbsf * The ASF licenses this file to You under the Apache License, Version 2.0
135c1278adef96d36fd421c536b1acc54a341cfbsf * (the "License"); you may not use this file except in compliance with
135c1278adef96d36fd421c536b1acc54a341cfbsf * the License. You may obtain a copy of the License at
135c1278adef96d36fd421c536b1acc54a341cfbsf * Unless required by applicable law or agreed to in writing, software
135c1278adef96d36fd421c536b1acc54a341cfbsf * distributed under the License is distributed on an "AS IS" BASIS,
135c1278adef96d36fd421c536b1acc54a341cfbsf * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135c1278adef96d36fd421c536b1acc54a341cfbsf * See the License for the specific language governing permissions and
135c1278adef96d36fd421c536b1acc54a341cfbsf * limitations under the License.
135c1278adef96d36fd421c536b1acc54a341cfbsf * This module makes it easy to restrict what HTTP methods can be ran against
135c1278adef96d36fd421c536b1acc54a341cfbsf * a server.
135c1278adef96d36fd421c536b1acc54a341cfbsf * It provides one comand:
135c1278adef96d36fd421c536b1acc54a341cfbsf * AllowMethods
135c1278adef96d36fd421c536b1acc54a341cfbsf * This command takes a list of HTTP methods to allow.
135c1278adef96d36fd421c536b1acc54a341cfbsf * The most common configuration should be like this:
135c1278adef96d36fd421c536b1acc54a341cfbsf * <Directory />
135c1278adef96d36fd421c536b1acc54a341cfbsf * AllowMethods GET HEAD OPTIONS
135c1278adef96d36fd421c536b1acc54a341cfbsf * </Directory>
135c1278adef96d36fd421c536b1acc54a341cfbsf * <Directory /special/cgi-bin>
135c1278adef96d36fd421c536b1acc54a341cfbsf * AllowMethods GET HEAD OPTIONS POST
135c1278adef96d36fd421c536b1acc54a341cfbsf * </Directory>
135c1278adef96d36fd421c536b1acc54a341cfbsf * Non-matching methods will be returned a status 405 (method not allowed)
135c1278adef96d36fd421c536b1acc54a341cfbsf * To allow all methods, and effectively turn off mod_allowmethods, use:
135c1278adef96d36fd421c536b1acc54a341cfbsf * AllowMethods reset
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc conf = (am_conf_t *) ap_get_module_config(r->per_dir_config,
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01623)
135c1278adef96d36fd421c536b1acc54a341cfbsf "client method denied by server configuration: '%s' to %s%s",
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletcstatic void *am_create_conf(apr_pool_t *p, char *dummy)
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc am_conf_t *conf = apr_pcalloc(p, sizeof(am_conf_t));
70ad0d9ff31ed8da58193eff4bf240247d1d6bddjailletcstatic void *am_merge_conf(apr_pool_t *pool, void *a, void *b)
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc am_conf_t *conf = apr_palloc(pool, sizeof(am_conf_t));
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletcstatic const char *am_allowmethods(cmd_parms *cmd, void *d, int argc,
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc char *const argv[])
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc if (argc == 0) {
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc return "AllowMethods: No method or 'reset' keyword given";
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc for (i = 0; i < argc; i++) {
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc return apr_pstrcat(cmd->pool, "AllowMethods: Invalid Method '",
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc ap_hook_access_checker(am_check_access, NULL, NULL, APR_HOOK_REALLY_FIRST);
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc AP_INIT_TAKE_ARGV("AllowMethods", am_allowmethods, NULL,
cf9acd789f86df61f77c735ec3a45b0f5c88bacbjailletc "only allow specific methods"),