MCPcopy Create free account
hub / github.com/apache/httpd / authenticate_basic_fake

Function authenticate_basic_fake

modules/aaa/mod_auth_basic.c:436–488  ·  view source on GitHub ↗

If requested, create a fake basic authentication header for the benefit * of a proxy or application running behind this server. */

Source from the content-addressed store, hash-verified

434 * of a proxy or application running behind this server.
435 */
436static int authenticate_basic_fake(request_rec *r)
437{
438 const char *auth_line, *user, *pass, *err;
439 auth_basic_config_rec *conf = ap_get_module_config(r->per_dir_config,
440 &auth_basic_module);
441
442 if (!conf->fakeuser) {
443 return DECLINED;
444 }
445
446 user = ap_expr_str_exec(r, conf->fakeuser, &err);
447 if (err) {
448 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02455)
449 "AuthBasicFake: could not evaluate user expression for URI '%s': %s", r->uri, err);
450 return HTTP_INTERNAL_SERVER_ERROR;
451 }
452 if (!user || !*user) {
453 ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02458)
454 "AuthBasicFake: empty username expression for URI '%s', ignoring", r->uri);
455
456 apr_table_unset(r->headers_in, "Authorization");
457
458 return DECLINED;
459 }
460
461 pass = ap_expr_str_exec(r, conf->fakepass, &err);
462 if (err) {
463 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02456)
464 "AuthBasicFake: could not evaluate password expression for URI '%s': %s", r->uri, err);
465 return HTTP_INTERNAL_SERVER_ERROR;
466 }
467 if (!pass || !*pass) {
468 ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02459)
469 "AuthBasicFake: empty password expression for URI '%s', ignoring", r->uri);
470
471 apr_table_unset(r->headers_in, "Authorization");
472
473 return DECLINED;
474 }
475
476 auth_line = apr_pstrcat(r->pool, "Basic ",
477 ap_pbase64encode(r->pool,
478 apr_pstrcat(r->pool, user,
479 ":", pass, NULL)),
480 NULL);
481 apr_table_setn(r->headers_in, "Authorization", auth_line);
482
483 ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02457)
484 "AuthBasicFake: \"Authorization: %s\"",
485 auth_line);
486
487 return OK;
488}
489
490static void register_hooks(apr_pool_t *p)
491{

Callers

nothing calls this directly

Calls 3

ap_get_module_configFunction · 0.85
ap_expr_str_execFunction · 0.85
ap_pbase64encodeFunction · 0.85

Tested by

no test coverage detected