Skip to content

Commit cb618b1

Browse files
committed
fix somme default directive value
1 parent 46efeb7 commit cb618b1

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

mod_auth_memcookie.c

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 1999-2004 The Apache Software Foundation
1+
/* Copyright 1999-2016 Mathieu CARBONNEAUX
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -343,7 +343,8 @@ static int Auth_memCookie_DoSetHeader(void*rec,const char *szKey, const char *sz
343343
return 1;
344344
}
345345

346-
/*
346+
/****************************************************************************
347+
*
347348
* Auth_memCookie_Return_Safe_Unauthorized
348349
*
349350
* potential security issue: if we return a login to the browser, we must
@@ -352,7 +353,8 @@ static int Auth_memCookie_DoSetHeader(void*rec,const char *szKey, const char *sz
352353
*
353354
* if the user has full control over the backend, the
354355
* AuthCookieDisableNoStore can be used to turn this off.
355-
*/
356+
*
357+
****************************************************************************/
356358
static int Auth_memCookie_Return_Safe_Unauthorized(request_rec *r)
357359
{
358360
strAuth_memCookie_config_rec *conf=NULL;
@@ -368,7 +370,7 @@ static int Auth_memCookie_Return_Safe_Unauthorized(request_rec *r)
368370
return HTTP_UNAUTHORIZED;
369371
}
370372

371-
/**************************************************
373+
/******************************************************************************
372374
*
373375
* Auth_memCookie_check_cookie
374376
*
@@ -379,7 +381,7 @@ static int Auth_memCookie_Return_Safe_Unauthorized(request_rec *r)
379381
*
380382
* It is up to the webmaster to ensure this screen displays a suitable login
381383
* form to give the user the opportunity to log in.
382-
**************************************************/
384+
*****************************************************************************/
383385
static int Auth_memCookie_check_cookie(request_rec *r)
384386
{
385387
strAuth_memCookie_config_rec *conf=NULL;
@@ -722,8 +724,28 @@ static const authz_provider Auth_memCookie_authz_group_provider = {
722724
&Auth_memCookie_authz_parse_config,
723725
};
724726

725-
#endif
727+
/**************************************************************
728+
*
729+
* hook_note_auth_failure
730+
*
731+
* Make http redirect when authentication/authorization fail.
732+
*
733+
*************************************************************/
734+
static int hook_note_auth_failure(request_rec * r, const char *auth_type)
735+
{
736+
if (strcasecmp(auth_type, "cookie"))
737+
return DECLINED;
738+
739+
auth_form_config_rec *conf = ap_get_module_config(r->per_dir_config,
740+
&auth_form_module);
741+
742+
if (conf->location && ap_strchr_c(conf->location, ':')) {
743+
apr_table_setn(r->err_headers_out, "Location", conf->location);
744+
}
745+
return OK;
746+
}
726747

748+
#endif
727749

728750
/**************************************************
729751
* register module hook
@@ -735,10 +757,15 @@ static void register_hooks(apr_pool_t *p)
735757
// apache >=2.3 model
736758
#if MODULE_MAGIC_NUMBER_MAJOR > 20051115
737759
ap_hook_check_authn(Auth_memCookie_check_cookie, NULL, NULL, APR_HOOK_FIRST, AP_AUTH_INTERNAL_PER_CONF);
760+
738761
ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "mcac-group",
739762
AUTHZ_PROVIDER_VERSION,
740763
&Auth_memCookie_authz_group_provider,
741764
AP_AUTH_INTERNAL_PER_CONF);
765+
766+
ap_hook_note_auth_failure(hook_note_auth_failure, NULL, NULL,
767+
APR_HOOK_MIDDLE);
768+
742769
#else
743770
// apache 2.0 to 2.2 model
744771
ap_hook_check_user_id(Auth_memCookie_check_cookie, NULL, NULL, APR_HOOK_FIRST);
@@ -761,7 +788,7 @@ static void *create_Auth_memCookie_dir_config(apr_pool_t *p, char *d)
761788
#if MODULE_MAGIC_NUMBER_MAJOR <= 20051115
762789
conf->nAuth_memCookie_GroupAuthoritative = 1; /* group are handled by this module by default */
763790
#endif
764-
conf->nAuth_memCookie_Authoritative = 0; /* not by default */
791+
conf->nAuth_memCookie_Authoritative = 1; /* is set by default */
765792
conf->nAuth_memCookie_authbasicfix = 1; /* fix header for php auth by default */
766793
conf->nAuth_memCookie_SetSessionHTTPHeader = 0; /* set session information in http header of authenticated user */
767794
conf->nAuth_memCookie_SetSessionHTTPHeaderEncode = 0; /* encode http header groups value by default */
@@ -812,18 +839,17 @@ static const command_rec Auth_memCookie_cmds[] =
812839
OR_AUTHCFG, "Set to 'off' to not reset object expiry time in memcache... is 'on' by default"),
813840
AP_INIT_FLAG ("Auth_memCookie_SetSessionHTTPHeader", ap_set_flag_slot,
814841
(void *)APR_OFFSETOF(strAuth_memCookie_config_rec, nAuth_memCookie_SetSessionHTTPHeader),
815-
OR_AUTHCFG, "Set to 'on' to set session information to http header of the authenticated users, no by default"),
842+
OR_AUTHCFG, "Set to 'on' to set session information to http header of the authenticated users, is set 'off' by default"),
816843
AP_INIT_FLAG ("Auth_memCookie_SetSessionHTTPHeaderEncode", ap_set_flag_slot,
817844
(void *)APR_OFFSETOF(strAuth_memCookie_config_rec, nAuth_memCookie_SetSessionHTTPHeaderEncode),
818-
OR_AUTHCFG, "Set to 'on' to mime64 encode session information to http header, no by default"),
845+
OR_AUTHCFG, "Set to 'on' to mime64 encode session information to http header, is set 'off' by default"),
819846
AP_INIT_TAKE1("Auth_memCookie_SetSessionHTTPHeaderPrefix", ap_set_string_slot,
820847
(void *)APR_OFFSETOF(strAuth_memCookie_config_rec, szAuth_memCookie_SetSessionHTTPHeaderPrefix),
821848
OR_AUTHCFG, "Set HTTP header prefix - set to 'MCAC_' by default"),
822849
AP_INIT_TAKE1("Auth_memCookie_CookieName", ap_set_string_slot,
823850
(void *)APR_OFFSETOF(strAuth_memCookie_config_rec, szAuth_memCookie_CookieName),
824851
OR_AUTHCFG, "Name of cookie to set"),
825-
AP_INIT_TAKE1 ( "Auth_memCookie_MatchIP_Mode", cmd_MatchIP_Mode,
826-
NULL,
852+
AP_INIT_TAKE1("Auth_memCookie_MatchIP_Mode", cmd_MatchIP_Mode, NULL,
827853
OR_AUTHCFG, "To check cookie ip adresse, Set to '1' to use 'X-Forwarded-For' http header, to '2' to use 'Via' http header, and to '3' to use apache remote_ip. set to '0' by default to desactivate the ip check."),
828854
#if MODULE_MAGIC_NUMBER_MAJOR <= 20051115
829855
AP_INIT_FLAG ("Auth_memCookie_GroupAuthoritative", ap_set_flag_slot,
@@ -832,7 +858,7 @@ static const command_rec Auth_memCookie_cmds[] =
832858
#endif
833859
AP_INIT_FLAG ("Auth_memCookie_Authoritative", ap_set_flag_slot,
834860
(void *)APR_OFFSETOF(strAuth_memCookie_config_rec, nAuth_memCookie_Authoritative),
835-
OR_AUTHCFG, "Set to 'on' to allow access control to be passed along to lower modules, is set to 'off' by default"),
861+
OR_AUTHCFG, "Set to 'off' to allow access control to be passed along to lower modules, is set to 'on' by default"),
836862
AP_INIT_FLAG ("Auth_memCookie_SilmulateAuthBasic", ap_set_flag_slot,
837863
(void *)APR_OFFSETOF(strAuth_memCookie_config_rec, nAuth_memCookie_authbasicfix),
838864
OR_AUTHCFG, "Set to 'off' to fix http header and auth_type for simulating auth basic for scripting language like php auth framework work, is set to 'on' by default"),

0 commit comments

Comments
 (0)