Skip to content

Commit

Permalink
add some resilience when both Forwarded and X-Forwarded-* are configured
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Zandbelt <[email protected]>
  • Loading branch information
zandbelt committed Aug 28, 2024
1 parent 7b796ca commit 918bcd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
08/28/2024
- re-introduce OIDCSessionMaxDuration 0; see #1252
- bump to 2.4.16.2dev
- add some resilience when both Forwarded and X-Forwarded-* are configured

08/26/2024
- fix parsing OIDCXForwardedHeaders; closes #1250; thanks @maltesmann
Expand Down
6 changes: 3 additions & 3 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ static const char *oidc_util_current_url_scheme(const request_rec *r, oidc_hdr_x

if (x_forwarded_headers & OIDC_HDR_FORWARDED)
scheme_str = oidc_http_hdr_forwarded_get(r, "proto");
else if (x_forwarded_headers & OIDC_HDR_X_FORWARDED_PROTO)
if ((scheme_str == NULL) && (x_forwarded_headers & OIDC_HDR_X_FORWARDED_PROTO))
scheme_str = oidc_http_hdr_in_x_forwarded_proto_get(r);

/* if not we'll determine the scheme used to connect to this server */
Expand Down Expand Up @@ -722,7 +722,7 @@ static const char *oidc_get_current_url_port(const request_rec *r, const char *s

if (x_forwarded_headers & OIDC_HDR_FORWARDED)
host_hdr = oidc_http_hdr_forwarded_get(r, "host");
else if (x_forwarded_headers & OIDC_HDR_X_FORWARDED_HOST)
if ((host_hdr == NULL) && (x_forwarded_headers & OIDC_HDR_X_FORWARDED_HOST))
host_hdr = oidc_http_hdr_in_x_forwarded_host_get(r);

if (host_hdr) {
Expand Down Expand Up @@ -782,7 +782,7 @@ const char *oidc_util_current_url_host(request_rec *r, oidc_hdr_x_forwarded_t x_

if (x_forwarded_headers & OIDC_HDR_FORWARDED)
host_str = oidc_http_hdr_forwarded_get(r, "host");
else if (x_forwarded_headers & OIDC_HDR_X_FORWARDED_HOST)
if ((host_str == NULL) && (x_forwarded_headers & OIDC_HDR_X_FORWARDED_HOST))
host_str = oidc_http_hdr_in_x_forwarded_host_get(r);

if (host_str == NULL)
Expand Down

0 comments on commit 918bcd6

Please sign in to comment.