Skip to content

Commit bd5a236

Browse files
committed
use refactored mTLS token binding and adhere to previous verify API
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
1 parent 1da447d commit bd5a236

1 file changed

Lines changed: 8 additions & 37 deletions

File tree

src/mod_oauth2.c

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
#include <apr_strings.h>
3939

40-
#include <mod_ssl.h>
41-
4240
OAUTH2_APACHE_LOG(oauth2)
4341

4442
// TODO: move the type into liboauth and use the Apache macro's (as in mod_sts)?
@@ -87,21 +85,6 @@ static void *oauth2_cfg_dir_merge(apr_pool_t *pool, void *b, void *a)
8785

8886
#define OAUTH2_REQUEST_STATE_KEY_CLAIMS "C"
8987

90-
APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
91-
APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup,
92-
(apr_pool_t *, server_rec *, conn_rec *, request_rec *,
93-
char *));
94-
95-
static APR_OPTIONAL_FN_TYPE(ssl_var_lookup) *oauth2_ssl_val = NULL;
96-
97-
const char *oauth2_conn_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c,
98-
request_rec *r, const char *var)
99-
{
100-
return (oauth2_ssl_val != NULL)
101-
? (const char *)oauth2_ssl_val(p, s, c, r, (char *)var)
102-
: NULL;
103-
}
104-
10588
static int oauth2_request_handler(oauth2_cfg_source_token_t *cfg,
10689
oauth2_cfg_token_verify_t *verify,
10790
oauth2_cfg_target_pass_t *target_pass,
@@ -129,9 +112,8 @@ static int oauth2_request_handler(oauth2_cfg_source_token_t *cfg,
129112
goto end;
130113
}
131114

132-
if (oauth2_token_verify(
133-
ctx->log, ctx->request, verify, source_token, &json_token,
134-
&oauth2_apache_server_callback_funcs, ctx->r) == false) {
115+
if (oauth2_token_verify(ctx->log, ctx->request, verify, source_token,
116+
&json_token) == false) {
135117
rv = oauth2_apache_return_www_authenticate(
136118
cfg, ctx, HTTP_UNAUTHORIZED, OAUTH2_ERROR_INVALID_TOKEN,
137119
"Token could not be verified.");
@@ -198,13 +180,6 @@ static int oauth2_check_user_id_handler(request_rec *r)
198180
"incoming request: \"%s?%s\" ap_is_initial_req=%d",
199181
r->parsed_uri.path, r->args, ap_is_initial_req(r));
200182

201-
/* workaround because the SSL CGI env var push happens only in the fixup
202-
* handler */
203-
const char *pem = oauth2_conn_ssl_val(r->pool, r->server, r->connection,
204-
r, "SSL_CLIENT_CERT");
205-
oauth2_apache_server_callback_funcs.set(ctx->log, ctx->r,
206-
"SSL_CLIENT_CERT", pem);
207-
208183
if (strcasecmp((const char *)ap_auth_type(r), OAUTH2_AUTH_TYPE) == 0)
209184
return oauth2_request_handler(cfg->source_token, cfg->verify,
210185
cfg->target_pass, ctx, true);
@@ -269,20 +244,16 @@ static const authz_provider oauth2_authz_claim_provider = {
269244

270245
OAUTH2_APACHE_HANDLERS(oauth2)
271246

272-
static apr_status_t oauth2_post_config_wrap(apr_pool_t *pool, apr_pool_t *p1,
273-
apr_pool_t *p2, server_rec *s)
274-
{
275-
oauth2_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
276-
return OAUTH2_APACHE_POST_CONFIG(oauth2)(pool, p1, p2, s);
277-
}
278-
279247
static void oauth2_register_hooks(apr_pool_t *p)
280248
{
281-
ap_hook_post_config(oauth2_post_config_wrap, NULL, NULL,
249+
ap_hook_post_config(OAUTH2_APACHE_POST_CONFIG(oauth2), NULL, NULL,
282250
APR_HOOK_MIDDLE);
283-
static const char *const authzSucc[] = {"mod_auth_openidc.c", NULL};
284-
ap_hook_check_authn(oauth2_check_user_id_handler, NULL, authzSucc,
251+
252+
static const char *const aszPre[] = {"mod_ssl.c", NULL};
253+
static const char *const aszSucc[] = {"mod_auth_openidc.c", NULL};
254+
ap_hook_check_authn(oauth2_check_user_id_handler, aszPre, aszSucc,
285255
APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF);
256+
286257
ap_register_auth_provider(
287258
p, AUTHZ_PROVIDER_GROUP, OAUTH2_REQUIRE_OAUTH2_CLAIM, "0",
288259
&oauth2_authz_claim_provider, AP_AUTH_INTERNAL_PER_CONF);

0 commit comments

Comments
 (0)