Hi all,

I've been using httpd's authentication & authorization modules for several
weeks. Compared to many other modules I used in the past, the debugging of
"auth deny" issues (caused by these modules) is really a pain in the ass.
The key problem is that httpd often does not tell *why* certain requests
are denied, but only give a very general message like,
    "[auth_basic:error] AH01617: user tixu: authentication failure for "/":
"
    "[authz_core:error] AH01631: user tixu: authorization failure for "/":"

In many cases, these two log messages are the only ones available for
debugging. But they really do not pinpoint the reason beneath the
authn/authz failures. Yes, these two logs are printed in `mod_auth_basic`
and `mod_authz_core` where the authn/authz results from different providers
are aggregated.

Even worse, things got much more complicated and hard to debug when
multiple authn/authz providers are applied (e.g., file + ldap + ssl). In
fact, these're not uncommon,
https://httpd.apache.org/docs/2.4/howto/auth.html#multprovider
Note that, with AH01617 and AH01631, we can't even know which module
actually denied the request!

Certainly, there are awesome auth modules like `mod_authz_owner` and
`mod_authz_dbm` which have excellent logging ---before each AUTH_DENIED, it
has error logs to pinpoint the precise reason (checkout
`fileowner_check_authorization(..)` in `mod_authz_owner.c` and
`dbmgroup_check_authorization(..)` in `mod_authz_dbm.c`).
https://github.com/apache/httpd/blob/trunk/modules/aaa/mod_authz_owner.c
https://github.com/apache/httpd/blob/trunk/modules/aaa/mod_authz_dbm.c

With such precise log msgs, we sysadmins can understand the problems and
take actions immediately.

Unfortunately, in many other cases, the authn/z modules keep silent and
thus ending with AH01617 and AH01631. The following shows two of the
examples,

static authz_status ssl_authz_require_ssl_check(...) { /*
ssl_engine_kernel.c */
    ...
    if (ssl)
        return AUTHZ_GRANTED;
    else
        return AUTHZ_DENIED;
}

and

static authz_status dbdgroup_check_authorization(...) { /* mod_authz_dbd.c
*/
    while (...) {
        ...
        return AUTHZ_GRANTED;
    }
    return AUTHZ_DENIED;
}

Such cases are not rare, but prevalent across several authn/authz modules.

I propose to apply the same good practices (such as mod_authz_owner &
mod_authz_dbm) to all the authn/authz modules. Basically, I want to add log
messages before each AUTHN/Z_DENIES to pinpoint:

1) which module denied the request
2) the reason the request gets denied

In this way, sysadmins can immediately understand the causes and take
actions (if necessary).

Any advice or feedback on this proposal is highly welcomed (that's the
whole purpose of this email)!

Specially, I want to understand whether this is something worth doing
(besides scratching my own itch)? Is there any concerns, or did I miss any
important things? Let me know!

Thanks a lot!
Tianyin

Reply via email to