Skip to content

Commit 1bfc6f5

Browse files
committed
use case insensitive domain comparison in oidc_check_cookie_domain
bump to 2.4.16.9dev Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 6ebf7e8 commit 1bfc6f5

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
03/18/2025
2+
- use case insensitive hostname/domain comparison in oidc_check_cookie_domain
3+
- bump to 2.4.16.9dev
4+
15
02/17/2025
26
- release 2.4.16.8
37

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([mod_auth_openidc],[2.4.16.8],[[email protected]])
1+
AC_INIT([mod_auth_openidc],[2.4.16.9dev],[[email protected]])
22

33
AC_SUBST(NAMEVER, AC_PACKAGE_TARNAME()-AC_PACKAGE_VERSION())
44

src/mod_auth_openidc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ static apr_byte_t oidc_check_max_session_duration(request_rec *r, oidc_cfg_t *cf
529529
* it also handles the case that a cookie is unexpectedly shared across multiple hosts in
530530
* name-based virtual hosting even though the OP(s) would be the same
531531
*/
532-
static apr_byte_t oidc_check_cookie_domain(request_rec *r, oidc_cfg_t *cfg, oidc_session_t *session) {
532+
apr_byte_t oidc_check_cookie_domain(request_rec *r, oidc_cfg_t *cfg, oidc_session_t *session) {
533533
const char *c_cookie_domain = oidc_cfg_cookie_domain_get(cfg)
534534
? oidc_cfg_cookie_domain_get(cfg)
535535
: oidc_util_current_url_host(r, oidc_cfg_x_forwarded_headers_get(cfg));
536536
const char *s_cookie_domain = oidc_session_get_cookie_domain(r, session);
537-
if ((s_cookie_domain == NULL) || (_oidc_strcmp(c_cookie_domain, s_cookie_domain) != 0)) {
537+
if ((s_cookie_domain == NULL) || (_oidc_strnatcasecmp(c_cookie_domain, s_cookie_domain) != 0)) {
538538
oidc_warn(r,
539539
"aborting: detected attempt to play cookie against a different domain/host than issued for! "
540540
"(issued=%s, current=%s)",

src/mod_auth_openidc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ apr_byte_t oidc_get_remote_user(request_rec *r, const char *claim_name, const ch
143143
json_t *json, char **request_user);
144144
apr_byte_t oidc_get_provider_from_session(request_rec *r, oidc_cfg_t *c, oidc_session_t *session,
145145
oidc_provider_t **provider);
146+
apr_byte_t oidc_check_cookie_domain(request_rec *r, oidc_cfg_t *cfg, oidc_session_t *session);
146147
apr_byte_t oidc_session_pass_tokens(request_rec *r, oidc_cfg_t *cfg, oidc_session_t *session, apr_byte_t extend_session,
147148
apr_byte_t *needs_save);
148149
void oidc_log_session_expires(request_rec *r, const char *msg, apr_time_t session_expires);

test/test.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,8 @@ static char *test_logout_request(request_rec *r) {
10731073
"https://idp.example.com/"
10741074
"endsession?post_logout_redirect_uri=https%3A%2F%2Fwww.example.com%2Floggedout&client_id=myclient&foo=bar");
10751075

1076+
oidc_session_free(r, session);
1077+
10761078
return 0;
10771079
}
10781080

@@ -1770,6 +1772,24 @@ static char *test_set_app_infos(request_rec *r) {
17701772
return 0;
17711773
}
17721774

1775+
static char *test_check_cookie_domain(request_rec *r) {
1776+
apr_byte_t rv = FALSE;
1777+
oidc_cfg_t *c = ap_get_module_config(r->server->module_config, &auth_openidc_module);
1778+
oidc_session_t *session = NULL;
1779+
1780+
oidc_session_load(r, &session);
1781+
oidc_session_set_cookie_domain(r, session, "ab001sb161djbn.xyz.com");
1782+
apr_table_set(r->headers_in, "Host", "ab001SB161djbn.xyz.com");
1783+
1784+
rv = oidc_check_cookie_domain(r, c, session);
1785+
1786+
TST_ASSERT_BYTE("oidc_check_cookie_domain", rv, TRUE);
1787+
1788+
oidc_session_free(r, session);
1789+
1790+
return 0;
1791+
}
1792+
17731793
static char *all_tests(apr_pool_t *pool, request_rec *r) {
17741794
char *message;
17751795
TST_RUN(test_private_key_parse, pool);
@@ -1815,6 +1835,7 @@ static char *all_tests(apr_pool_t *pool, request_rec *r) {
18151835
#endif
18161836

18171837
TST_RUN(test_logout_request, r);
1838+
TST_RUN(test_check_cookie_domain, r);
18181839

18191840
return 0;
18201841
}

0 commit comments

Comments
 (0)