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