/* optional function - look it up once in post_config */
static ap_dbd_t *(*authn_dbd_acquire_fn)(request_rec*) = NULL;
static void (*authn_dbd_prepare_fn)(server_rec*, const char*, const char*) = NULL;
+static APR_OPTIONAL_FN_TYPE(ap_authn_cache_store) *authn_cache_store = NULL;
+#define AUTHN_CACHE_STORE(r,user,realm,data) \
+ if (authn_cache_store != NULL) \
+ authn_cache_store((r), "dbd", (user), (realm), (data))
static void *authn_dbd_cr_conf(apr_pool_t *pool, char *dummy)
{
if (!dbd_password) {
return AUTH_USER_NOT_FOUND;
}
+ AUTHN_CACHE_STORE(r, user, NULL, dbd_password);
rv = apr_password_validate(password, dbd_password);
if (!dbd_hash) {
return AUTH_USER_NOT_FOUND;
}
-
+ AUTHN_CACHE_STORE(r, user, realm, dbd_hash);
*rethash = apr_pstrdup(r->pool, dbd_hash);
return AUTH_USER_FOUND;
}
+static void opt_retr(void)
+{
+ authn_cache_store = APR_RETRIEVE_OPTIONAL_FN(ap_authn_cache_store);
+}
static void authn_dbd_hooks(apr_pool_t *p)
{
static const authn_provider authn_dbd_provider = {
ap_register_auth_provider(p, AUTHN_PROVIDER_GROUP, "dbd",
AUTHN_PROVIDER_VERSION,
&authn_dbd_provider, AP_AUTH_INTERNAL_PER_CONF);
+ ap_hook_optional_fn_retrieve(opt_retr, NULL, NULL, APR_HOOK_MIDDLE);
}
AP_DECLARE_MODULE(authn_dbd) =
{
#include "mod_auth.h"
+static APR_OPTIONAL_FN_TYPE(ap_authn_cache_store) *authn_cache_store = NULL;
+#define AUTHN_CACHE_STORE(r,user,realm,data) \
+ if (authn_cache_store != NULL) \
+ authn_cache_store((r), "dbm", (user), (realm), (data))
+
typedef struct {
const char *pwfile;
const char *dbmtype;
if (colon_pw) {
*colon_pw = '\0';
}
+ AUTHN_CACHE_STORE(r, user, NULL, dbm_password);
rv = apr_password_validate(password, dbm_password);
}
*rethash = dbm_hash;
+ AUTHN_CACHE_STORE(r, user, realm, dbm_hash);
return AUTH_USER_FOUND;
}
&get_dbm_realm_hash,
};
+static void opt_retr(void)
+{
+ authn_cache_store = APR_RETRIEVE_OPTIONAL_FN(ap_authn_cache_store);
+}
static void register_hooks(apr_pool_t *p)
{
ap_register_auth_provider(p, AUTHN_PROVIDER_GROUP, "dbm",
AUTHN_PROVIDER_VERSION,
&authn_dbm_provider, AP_AUTH_INTERNAL_PER_CONF);
+ ap_hook_optional_fn_retrieve(opt_retr, NULL, NULL, APR_HOOK_MIDDLE);
}
AP_DECLARE_MODULE(authn_dbm) =
char *pwfile;
} authn_file_config_rec;
+static APR_OPTIONAL_FN_TYPE(ap_authn_cache_store) *authn_cache_store = NULL;
+#define AUTHN_CACHE_STORE(r,user,realm,data) \
+ if (authn_cache_store != NULL) \
+ authn_cache_store((r), "file", (user), (realm), (data))
+
static void *create_authn_file_dir_config(apr_pool_t *p, char *d)
{
authn_file_config_rec *conf = apr_palloc(p, sizeof(*conf));
if (!file_password) {
return AUTH_USER_NOT_FOUND;
}
+ AUTHN_CACHE_STORE(r, user, NULL, file_password);
status = apr_password_validate(password, file_password);
if (status != APR_SUCCESS) {
}
*rethash = file_hash;
+ AUTHN_CACHE_STORE(r, user, realm, file_hash);
return AUTH_USER_FOUND;
}
&get_realm_hash,
};
+static void opt_retr(void)
+{
+ authn_cache_store = APR_RETRIEVE_OPTIONAL_FN(ap_authn_cache_store);
+}
static void register_hooks(apr_pool_t *p)
{
ap_register_auth_provider(p, AUTHN_PROVIDER_GROUP, "file",
AUTHN_PROVIDER_VERSION,
&authn_file_provider, AP_AUTH_INTERNAL_PER_CONF);
+ ap_hook_optional_fn_retrieve(opt_retr, NULL, NULL, APR_HOOK_MIDDLE);
}
AP_DECLARE_MODULE(authn_file) =