|
37 | 37 |
|
38 | 38 | #include <apr_strings.h> |
39 | 39 |
|
40 | | -#include <mod_ssl.h> |
41 | | - |
42 | 40 | OAUTH2_APACHE_LOG(oauth2) |
43 | 41 |
|
44 | 42 | // 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) |
87 | 85 |
|
88 | 86 | #define OAUTH2_REQUEST_STATE_KEY_CLAIMS "C" |
89 | 87 |
|
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 | | - |
105 | 88 | static int oauth2_request_handler(oauth2_cfg_source_token_t *cfg, |
106 | 89 | oauth2_cfg_token_verify_t *verify, |
107 | 90 | oauth2_cfg_target_pass_t *target_pass, |
@@ -129,9 +112,8 @@ static int oauth2_request_handler(oauth2_cfg_source_token_t *cfg, |
129 | 112 | goto end; |
130 | 113 | } |
131 | 114 |
|
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) { |
135 | 117 | rv = oauth2_apache_return_www_authenticate( |
136 | 118 | cfg, ctx, HTTP_UNAUTHORIZED, OAUTH2_ERROR_INVALID_TOKEN, |
137 | 119 | "Token could not be verified."); |
@@ -198,13 +180,6 @@ static int oauth2_check_user_id_handler(request_rec *r) |
198 | 180 | "incoming request: \"%s?%s\" ap_is_initial_req=%d", |
199 | 181 | r->parsed_uri.path, r->args, ap_is_initial_req(r)); |
200 | 182 |
|
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 | | - |
208 | 183 | if (strcasecmp((const char *)ap_auth_type(r), OAUTH2_AUTH_TYPE) == 0) |
209 | 184 | return oauth2_request_handler(cfg->source_token, cfg->verify, |
210 | 185 | cfg->target_pass, ctx, true); |
@@ -269,20 +244,16 @@ static const authz_provider oauth2_authz_claim_provider = { |
269 | 244 |
|
270 | 245 | OAUTH2_APACHE_HANDLERS(oauth2) |
271 | 246 |
|
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 | | - |
279 | 247 | static void oauth2_register_hooks(apr_pool_t *p) |
280 | 248 | { |
281 | | - ap_hook_post_config(oauth2_post_config_wrap, NULL, NULL, |
| 249 | + ap_hook_post_config(OAUTH2_APACHE_POST_CONFIG(oauth2), NULL, NULL, |
282 | 250 | 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, |
285 | 255 | APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF); |
| 256 | + |
286 | 257 | ap_register_auth_provider( |
287 | 258 | p, AUTHZ_PROVIDER_GROUP, OAUTH2_REQUIRE_OAUTH2_CLAIM, "0", |
288 | 259 | &oauth2_authz_claim_provider, AP_AUTH_INTERNAL_PER_CONF); |
|
0 commit comments