@@ -573,7 +573,8 @@ OIDC_CFG_MEMBER_FUNCS_BOOL(cookie_http_only, OIDC_DEFAULT_COOKIE_HTTPONLY)
573573/*
574574 * define which header we use for calculating the fingerprint of the state during authentication
575575 */
576- const char * oidc_cmd_cookie_same_site_set (cmd_parms * cmd , void * m , const char * arg ) {
576+ const char * oidc_cmd_cookie_same_site_session_set (cmd_parms * cmd , void * m , const char * arg1 , const char * arg2 ,
577+ const char * arg3 ) {
577578 oidc_cfg_t * cfg = (oidc_cfg_t * )ap_get_module_config (cmd -> server -> module_config , & auth_openidc_module );
578579 // NB: On is made equal to Lax here and Off is equal to None (backwards compatibility)
579580 static const oidc_cfg_option_t options [ ] = {{OIDC_SAMESITE_COOKIE_NONE , OIDC_SAMESITE_COOKIE_OFF_STR },
@@ -582,13 +583,34 @@ const char *oidc_cmd_cookie_same_site_set(cmd_parms *cmd, void *m, const char *a
582583 {OIDC_SAMESITE_COOKIE_NONE , OIDC_SAMESITE_COOKIE_NONE_STR },
583584 {OIDC_SAMESITE_COOKIE_LAX , OIDC_SAMESITE_COOKIE_LAX_STR },
584585 {OIDC_SAMESITE_COOKIE_STRICT , OIDC_SAMESITE_COOKIE_STRICT_STR }};
585- const char * rv = oidc_cfg_parse_option_ignore_case (cmd -> pool , options , OIDC_CFG_OPTIONS_SIZE (options ), arg ,
586- & cfg -> cookie_same_site );
586+ const char * rv = oidc_cfg_parse_option_ignore_case (cmd -> pool , options , OIDC_CFG_OPTIONS_SIZE (options ), arg1 ,
587+ & cfg -> cookie_same_site_session );
588+ if ((rv == NULL ) && (arg2 != NULL )) {
589+ static const oidc_cfg_option_t state_options [] = {
590+ {OIDC_SAMESITE_COOKIE_NONE , OIDC_SAMESITE_COOKIE_OFF_STR },
591+ {OIDC_SAMESITE_COOKIE_LAX , OIDC_SAMESITE_COOKIE_ON_STR },
592+ {OIDC_SAMESITE_COOKIE_DISABLED , OIDC_SAMESITE_COOKIE_DISABLED_STR },
593+ {OIDC_SAMESITE_COOKIE_NONE , OIDC_SAMESITE_COOKIE_NONE_STR },
594+ {OIDC_SAMESITE_COOKIE_LAX , OIDC_SAMESITE_COOKIE_LAX_STR }};
595+ rv = oidc_cfg_parse_option_ignore_case (cmd -> pool , state_options , OIDC_CFG_OPTIONS_SIZE (state_options ),
596+ arg2 , & cfg -> cookie_same_site_state );
597+ }
598+ if ((rv == NULL ) && (arg3 != NULL )) {
599+ rv = oidc_cfg_parse_option_ignore_case (cmd -> pool , options , OIDC_CFG_OPTIONS_SIZE (options ), arg3 ,
600+ & cfg -> cookie_same_site_discovery_csrf );
601+ }
587602 return OIDC_CONFIG_DIR_RV (cmd , rv );
588603}
589604
590605#define OIDC_DEFAULT_COOKIE_SAME_SITE OIDC_SAMESITE_COOKIE_LAX
591- OIDC_CFG_MEMBER_FUNC_TYPE_GET (cookie_same_site , oidc_samesite_cookie_t , OIDC_DEFAULT_COOKIE_SAME_SITE )
606+ OIDC_CFG_MEMBER_FUNC_TYPE_GET (cookie_same_site_session , oidc_samesite_cookie_t , OIDC_DEFAULT_COOKIE_SAME_SITE )
607+
608+ #define OIDC_DEFAULT_COOKIE_SAME_SITE_STATE oidc_cfg_cookie_same_site_session_get (cfg )
609+ OIDC_CFG_MEMBER_FUNC_TYPE_GET (cookie_same_site_state , oidc_samesite_cookie_t , OIDC_DEFAULT_COOKIE_SAME_SITE_STATE )
610+
611+ #define OIDC_DEFAULT_COOKIE_SAME_SITE_CSRF_DISCOVERY oidc_cfg_cookie_same_site_session_get(cfg)
612+ OIDC_CFG_MEMBER_FUNC_TYPE_GET (cookie_same_site_discovery_csrf , oidc_samesite_cookie_t ,
613+ OIDC_DEFAULT_COOKIE_SAME_SITE_CSRF_DISCOVERY )
592614
593615#define OIDC_DEFAULT_SESSION_FALLBACK_TO_COOKIE 0
594616OIDC_CFG_MEMBER_FUNCS_BOOL (session_cache_fallback_to_cookie , OIDC_DEFAULT_SESSION_FALLBACK_TO_COOKIE )
@@ -710,7 +732,10 @@ void *oidc_cfg_server_create(apr_pool_t *pool, server_rec *svr) {
710732 c -> remote_user_claim .reg_exp = NULL ;
711733 c -> remote_user_claim .replace = NULL ;
712734 c -> cookie_http_only = OIDC_CONFIG_POS_INT_UNSET ;
713- c -> cookie_same_site = OIDC_CONFIG_POS_INT_UNSET ;
735+
736+ c -> cookie_same_site_session = OIDC_CONFIG_POS_INT_UNSET ;
737+ c -> cookie_same_site_state = OIDC_CONFIG_POS_INT_UNSET ;
738+ c -> cookie_same_site_discovery_csrf = OIDC_CONFIG_POS_INT_UNSET ;
714739
715740 c -> outgoing_proxy .host_port = NULL ;
716741 c -> outgoing_proxy .username_password = NULL ;
@@ -834,8 +859,16 @@ void *oidc_cfg_server_merge(apr_pool_t *pool, void *BASE, void *ADD) {
834859
835860 c -> cookie_http_only =
836861 add -> cookie_http_only != OIDC_CONFIG_POS_INT_UNSET ? add -> cookie_http_only : base -> cookie_http_only ;
837- c -> cookie_same_site =
838- add -> cookie_same_site != OIDC_CONFIG_POS_INT_UNSET ? add -> cookie_same_site : base -> cookie_same_site ;
862+
863+ c -> cookie_same_site_session = add -> cookie_same_site_session != OIDC_CONFIG_POS_INT_UNSET
864+ ? add -> cookie_same_site_session
865+ : base -> cookie_same_site_session ;
866+ c -> cookie_same_site_state = add -> cookie_same_site_state != OIDC_CONFIG_POS_INT_UNSET
867+ ? add -> cookie_same_site_state
868+ : base -> cookie_same_site_state ;
869+ c -> cookie_same_site_discovery_csrf = add -> cookie_same_site_discovery_csrf != OIDC_CONFIG_POS_INT_UNSET
870+ ? add -> cookie_same_site_discovery_csrf
871+ : base -> cookie_same_site_discovery_csrf ;
839872
840873 if (add -> outgoing_proxy .host_port != NULL ) {
841874 c -> outgoing_proxy .host_port = add -> outgoing_proxy .host_port ;
0 commit comments