|
|
495d07 |
Index: server/request.c
|
|
|
495d07 |
===================================================================
|
|
|
495d07 |
--- a/server/request.c (revision 1684524)
|
|
|
495d07 |
+++ b/server/request.c (revision 1684525)
|
|
|
495d07 |
@@ -71,6 +71,7 @@
|
|
|
495d07 |
APR_HOOK_LINK(create_request)
|
|
|
495d07 |
APR_HOOK_LINK(post_perdir_config)
|
|
|
495d07 |
APR_HOOK_LINK(dirwalk_stat)
|
|
|
495d07 |
+ APR_HOOK_LINK(force_authn)
|
|
|
495d07 |
)
|
|
|
495d07 |
|
|
|
495d07 |
AP_IMPLEMENT_HOOK_RUN_FIRST(int,translate_name,
|
|
|
495d07 |
@@ -97,6 +98,8 @@
|
|
|
495d07 |
AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t,dirwalk_stat,
|
|
|
495d07 |
(apr_finfo_t *finfo, request_rec *r, apr_int32_t wanted),
|
|
|
495d07 |
(finfo, r, wanted), AP_DECLINED)
|
|
|
495d07 |
+AP_IMPLEMENT_HOOK_RUN_FIRST(int,force_authn,
|
|
|
495d07 |
+ (request_rec *r), (r), DECLINED)
|
|
|
495d07 |
|
|
|
495d07 |
static int auth_internal_per_conf = 0;
|
|
|
495d07 |
static int auth_internal_per_conf_hooks = 0;
|
|
|
495d07 |
@@ -118,6 +121,39 @@
|
|
|
495d07 |
}
|
|
|
495d07 |
}
|
|
|
495d07 |
|
|
|
495d07 |
+AP_DECLARE(int) ap_some_authn_required(request_rec *r)
|
|
|
495d07 |
+{
|
|
|
495d07 |
+ int access_status;
|
|
|
495d07 |
+
|
|
|
495d07 |
+ switch (ap_satisfies(r)) {
|
|
|
495d07 |
+ case SATISFY_ALL:
|
|
|
495d07 |
+ case SATISFY_NOSPEC:
|
|
|
495d07 |
+ if ((access_status = ap_run_access_checker(r)) != OK) {
|
|
|
495d07 |
+ break;
|
|
|
495d07 |
+ }
|
|
|
495d07 |
+
|
|
|
495d07 |
+ access_status = ap_run_access_checker_ex(r);
|
|
|
495d07 |
+ if (access_status == DECLINED) {
|
|
|
495d07 |
+ return TRUE;
|
|
|
495d07 |
+ }
|
|
|
495d07 |
+
|
|
|
495d07 |
+ break;
|
|
|
495d07 |
+ case SATISFY_ANY:
|
|
|
495d07 |
+ if ((access_status = ap_run_access_checker(r)) == OK) {
|
|
|
495d07 |
+ break;
|
|
|
495d07 |
+ }
|
|
|
495d07 |
+
|
|
|
495d07 |
+ access_status = ap_run_access_checker_ex(r);
|
|
|
495d07 |
+ if (access_status == DECLINED) {
|
|
|
495d07 |
+ return TRUE;
|
|
|
495d07 |
+ }
|
|
|
495d07 |
+
|
|
|
495d07 |
+ break;
|
|
|
495d07 |
+ }
|
|
|
495d07 |
+
|
|
|
495d07 |
+ return FALSE;
|
|
|
495d07 |
+}
|
|
|
495d07 |
+
|
|
|
495d07 |
/* This is the master logic for processing requests. Do NOT duplicate
|
|
|
495d07 |
* this logic elsewhere, or the security model will be broken by future
|
|
|
495d07 |
* API changes. Each phase must be individually optimized to pick up
|
|
|
495d07 |
@@ -232,15 +268,8 @@
|
|
|
495d07 |
}
|
|
|
495d07 |
|
|
|
495d07 |
access_status = ap_run_access_checker_ex(r);
|
|
|
495d07 |
- if (access_status == OK) {
|
|
|
495d07 |
- ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
|
|
|
495d07 |
- "request authorized without authentication by "
|
|
|
495d07 |
- "access_checker_ex hook: %s", r->uri);
|
|
|
495d07 |
- }
|
|
|
495d07 |
- else if (access_status != DECLINED) {
|
|
|
495d07 |
- return decl_die(access_status, "check access", r);
|
|
|
495d07 |
- }
|
|
|
495d07 |
- else {
|
|
|
495d07 |
+ if (access_status == DECLINED
|
|
|
495d07 |
+ || (access_status == OK && ap_run_force_authn(r) == OK)) {
|
|
|
495d07 |
if ((access_status = ap_run_check_user_id(r)) != OK) {
|
|
|
495d07 |
return decl_die(access_status, "check user", r);
|
|
|
495d07 |
}
|
|
|
495d07 |
@@ -258,6 +287,14 @@
|
|
|
495d07 |
return decl_die(access_status, "check authorization", r);
|
|
|
495d07 |
}
|
|
|
495d07 |
}
|
|
|
495d07 |
+ else if (access_status == OK) {
|
|
|
495d07 |
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
|
|
|
495d07 |
+ "request authorized without authentication by "
|
|
|
495d07 |
+ "access_checker_ex hook: %s", r->uri);
|
|
|
495d07 |
+ }
|
|
|
495d07 |
+ else {
|
|
|
495d07 |
+ return decl_die(access_status, "check access", r);
|
|
|
495d07 |
+ }
|
|
|
495d07 |
break;
|
|
|
495d07 |
case SATISFY_ANY:
|
|
|
495d07 |
if ((access_status = ap_run_access_checker(r)) == OK) {
|
|
|
495d07 |
@@ -269,15 +306,8 @@
|
|
|
495d07 |
}
|
|
|
495d07 |
|
|
|
495d07 |
access_status = ap_run_access_checker_ex(r);
|
|
|
495d07 |
- if (access_status == OK) {
|
|
|
495d07 |
- ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
|
|
|
495d07 |
- "request authorized without authentication by "
|
|
|
495d07 |
- "access_checker_ex hook: %s", r->uri);
|
|
|
495d07 |
- }
|
|
|
495d07 |
- else if (access_status != DECLINED) {
|
|
|
495d07 |
- return decl_die(access_status, "check access", r);
|
|
|
495d07 |
- }
|
|
|
495d07 |
- else {
|
|
|
495d07 |
+ if (access_status == DECLINED
|
|
|
495d07 |
+ || (access_status == OK && ap_run_force_authn(r) == OK)) {
|
|
|
495d07 |
if ((access_status = ap_run_check_user_id(r)) != OK) {
|
|
|
495d07 |
return decl_die(access_status, "check user", r);
|
|
|
495d07 |
}
|
|
|
495d07 |
@@ -295,6 +325,14 @@
|
|
|
495d07 |
return decl_die(access_status, "check authorization", r);
|
|
|
495d07 |
}
|
|
|
495d07 |
}
|
|
|
495d07 |
+ else if (access_status == OK) {
|
|
|
495d07 |
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r,
|
|
|
495d07 |
+ "request authorized without authentication by "
|
|
|
495d07 |
+ "access_checker_ex hook: %s", r->uri);
|
|
|
495d07 |
+ }
|
|
|
495d07 |
+ else {
|
|
|
495d07 |
+ return decl_die(access_status, "check access", r);
|
|
|
495d07 |
+ }
|
|
|
495d07 |
break;
|
|
|
495d07 |
}
|
|
|
495d07 |
}
|
|
|
495d07 |
Index: include/http_request.h
|
|
|
495d07 |
===================================================================
|
|
|
495d07 |
--- a/include/http_request.h 2015/06/09 20:41:28 1684524
|
|
|
495d07 |
+++ b/include/http_request.h 2015/06/09 20:42:44 1684525
|
|
|
495d07 |
@@ -185,6 +185,8 @@
|
|
|
495d07 |
* is required for the current request
|
|
|
495d07 |
* @param r The current request
|
|
|
495d07 |
* @return 1 if authentication is required, 0 otherwise
|
|
|
495d07 |
+ * @bug Behavior changed in 2.4.x refactoring, API no longer usable
|
|
|
495d07 |
+ * @deprecated @see ap_some_authn_required()
|
|
|
495d07 |
*/
|
|
|
495d07 |
AP_DECLARE(int) ap_some_auth_required(request_rec *r);
|
|
|
495d07 |
|
|
|
495d07 |
@@ -539,6 +541,16 @@
|
|
|
495d07 |
AP_DECLARE_HOOK(int,post_perdir_config,(request_rec *r))
|
|
|
495d07 |
|
|
|
495d07 |
/**
|
|
|
495d07 |
+ * This hook allows a module to force authn to be required when
|
|
|
495d07 |
+ * processing a request.
|
|
|
495d07 |
+ * This hook should be registered with ap_hook_force_authn().
|
|
|
495d07 |
+ * @param r The current request
|
|
|
495d07 |
+ * @return OK (force authn), DECLINED (let later modules decide)
|
|
|
495d07 |
+ * @ingroup hooks
|
|
|
495d07 |
+ */
|
|
|
495d07 |
+AP_DECLARE_HOOK(int,force_authn,(request_rec *r))
|
|
|
495d07 |
+
|
|
|
495d07 |
+/**
|
|
|
495d07 |
* This hook allows modules to handle/emulate the apr_stat() calls
|
|
|
495d07 |
* needed for directory walk.
|
|
|
495d07 |
* @param finfo where to put the stat data
|
|
|
495d07 |
@@ -584,6 +596,17 @@
|
|
|
495d07 |
AP_DECLARE(apr_bucket *) ap_bucket_eor_create(apr_bucket_alloc_t *list,
|
|
|
495d07 |
request_rec *r);
|
|
|
495d07 |
|
|
|
495d07 |
+/**
|
|
|
495d07 |
+ * Can be used within any handler to determine if any authentication
|
|
|
495d07 |
+ * is required for the current request. Note that if used with an
|
|
|
495d07 |
+ * access_checker hook, an access_checker_ex hook or an authz provider; the
|
|
|
495d07 |
+ * caller should take steps to avoid a loop since this function is
|
|
|
495d07 |
+ * implemented by calling these hooks.
|
|
|
495d07 |
+ * @param r The current request
|
|
|
495d07 |
+ * @return TRUE if authentication is required, FALSE otherwise
|
|
|
495d07 |
+ */
|
|
|
495d07 |
+AP_DECLARE(int) ap_some_authn_required(request_rec *r);
|
|
|
495d07 |
+
|
|
|
495d07 |
#ifdef __cplusplus
|
|
|
495d07 |
}
|
|
|
495d07 |
#endif
|