From fcb94d7ab5660fb047507c7565f04759611272e1 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 12 Feb 2010 19:53:15 +0000 Subject: Handle logout path ourselves, if it doesn't exist. --- module/mod_auth_singleid.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'module/mod_auth_singleid.c') diff --git a/module/mod_auth_singleid.c b/module/mod_auth_singleid.c index e9e6a0a..4520009 100644 --- a/module/mod_auth_singleid.c +++ b/module/mod_auth_singleid.c @@ -1195,16 +1195,10 @@ hook_authenticate (request_rec* r) compare_paths ("/robots.txt", r->uri) == 0) return OK; - /* Should we logout? */ + /* The logout path is not authenticated.*/ if (compare_paths (ctx->logout_path, r->uri) == 0) { session_send_clear (ctx, r); - if (ctx->logout_dest) { - sid_request_respond_headers (&req, 302, "Found", - "Location", ctx->logout_dest, - "Cache-Control", "no-cache", - NULL); - } - return req.result; + return OK; } mainreq = r; @@ -1261,6 +1255,41 @@ hook_authenticate (request_rec* r) return req.result; } +static int +hook_handler (request_rec *r) +{ + sid_request_t req; + sid_context_t *ctx; + const char* authtype; + + /* Make sure it's for us */ + if (!(authtype = ap_auth_type (r)) || strcasecmp (SID_AUTHTYPE, authtype) != 0) + return DECLINED; + + ctx = (sid_context_t*)ap_get_module_config (r->per_dir_config, &auth_singleid_module); + if (ctx->identifier == NULL) + return DECLINED; + + /* Handle the logout redirect properly.*/ + if (compare_paths (ctx->logout_path, r->uri) == 0) { + if (ctx->logout_dest) { + + req.result = OK; + req.rec = r; + req.sess = NULL; + req.output = NULL; + + sid_request_respond_headers (&req, 302, "Found", + "Location", ctx->logout_dest, + "Cache-Control", "no-cache", + NULL); + return req.result; + } + } + + return DECLINED; +} + static int hook_access(request_rec *r) { @@ -1322,6 +1351,7 @@ static void register_hooks(apr_pool_t *p) { ap_hook_post_config (hook_initialize, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_handler (hook_handler, NULL, NULL, APR_HOOK_FIRST); ap_hook_child_init (hook_child, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_check_user_id (hook_authenticate, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_auth_checker (hook_access, NULL, NULL, APR_HOOK_MIDDLE); -- cgit v1.2.3