Skip to content

Commit 94f832f

Browse files
committed
improve basic authentication parsing for OIDCOAuthAcceptTokenAs basic
Signed-off-by: Hans Zandbelt <[email protected]>
1 parent f7beb71 commit 94f832f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
09/09/2024
22
- fix accepting custom cookie names in OIDCOAuthAcceptTokenAs cookie:<name>; see #1261; thanks @bbartke
33
- bump to 2.4.16.4rc0
4+
- improve basic authentication parsing when using OIDCOAuthAcceptTokenAs basic
45

56
09/06/2024
67
- allow overriding globally set OIDCCacheType back to shm in vhosts

src/oauth.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ apr_byte_t oidc_oauth_get_bearer_token(request_rec *r, const char **access_token
210210
oidc_debug(r, "authorization header found");
211211

212212
apr_byte_t known_scheme = 0;
213+
char *scheme = ap_getword(r->pool, &auth_line, OIDC_CHAR_SPACE);
213214

214215
/* look for the Bearer keyword */
215-
if ((_oidc_strnatcasecmp(ap_getword(r->pool, &auth_line, OIDC_CHAR_SPACE), OIDC_PROTO_BEARER) ==
216-
0) &&
216+
if ((_oidc_strnatcasecmp(scheme, OIDC_PROTO_BEARER) == 0) &&
217217
(accept_token_in & OIDC_OAUTH_ACCEPT_TOKEN_IN_HEADER)) {
218218

219219
/* skip any spaces after the Bearer keyword */
@@ -226,7 +226,8 @@ apr_byte_t oidc_oauth_get_bearer_token(request_rec *r, const char **access_token
226226

227227
known_scheme = 1;
228228

229-
} else if (accept_token_in & OIDC_OAUTH_ACCEPT_TOKEN_IN_BASIC) {
229+
} else if ((_oidc_strnatcasecmp(scheme, OIDC_PROTO_BASIC) == 0) &&
230+
(accept_token_in & OIDC_OAUTH_ACCEPT_TOKEN_IN_BASIC)) {
230231

231232
char *decoded_line;
232233
int decoded_len;
@@ -244,7 +245,7 @@ apr_byte_t oidc_oauth_get_bearer_token(request_rec *r, const char **access_token
244245
}
245246

246247
if (known_scheme == 0) {
247-
oidc_warn(r, "client used unsupported authentication scheme: %s", r->uri);
248+
oidc_warn(r, "client used unsupported authentication scheme: %s", scheme);
248249
}
249250
}
250251
}

0 commit comments

Comments
 (0)