@@ -559,9 +559,10 @@ function assertNoWarningErrorMessages()
559559 function http_post (
560560 string $ phpfile ,
561561 array $ post_data ,
562- array $ query_parameters = [],
562+ array $ query_params = [],
563563 bool $ do_generate_csrf_token = true ,
564564 bool $ do_validate_messages = true ,
565+ ?string $ bearer_token = null ,
565566 ): string {
566567 global $ LDAP ,
567568 $ SQL ,
@@ -580,11 +581,14 @@ function http_post(
580581 $ _SERVER ["REQUEST_METHOD " ] = "POST " ;
581582 $ _SERVER ["PHP_SELF " ] = _preg_replace ("/.*webroot\// " , "/ " , $ phpfile );
582583 $ _SERVER ["REQUEST_URI " ] = _preg_replace ("/.*webroot\// " , "/ " , $ phpfile ); // Slightly imprecise because it doesn't include get parameters
584+ if ($ bearer_token !== null ) {
585+ $ _SERVER ["HTTP_AUTHORIZATION " ] = "Bearer $ bearer_token " ;
586+ }
583587 if (!array_key_exists ("csrf_token " , $ post_data ) && $ do_generate_csrf_token ) {
584588 $ post_data ["csrf_token " ] = CSRFToken::generate ();
585589 }
586590 $ _POST = $ post_data ;
587- $ _GET = $ query_parameters ;
591+ $ _GET = $ query_params ;
588592 ob_start ();
589593 try {
590594 $ post_did_redirect_or_die = false ;
@@ -609,8 +613,9 @@ function http_post(
609613
610614 function http_get (
611615 string $ phpfile ,
612- array $ get_data = [],
616+ array $ query_params = [],
613617 bool $ ignore_die = false ,
618+ ?string $ bearer_token = null ,
614619 $ do_validate_messages = true ,
615620 ): string {
616621 global $ LDAP ,
@@ -630,7 +635,10 @@ function http_get(
630635 $ _SERVER ["REQUEST_METHOD " ] = "GET " ;
631636 $ _SERVER ["PHP_SELF " ] = _preg_replace ("/.*webroot\// " , "/ " , $ phpfile );
632637 $ _SERVER ["REQUEST_URI " ] = _preg_replace ("/.*webroot\// " , "/ " , $ phpfile ); // Slightly imprecise because it doesn't include get parameters
633- $ _GET = $ get_data ;
638+ if ($ bearer_token !== null ) {
639+ $ _SERVER ["HTTP_AUTHORIZATION " ] = "Bearer $ bearer_token " ;
640+ }
641+ $ _GET = $ query_params ;
634642 ob_start ();
635643 try {
636644 include $ phpfile ;
0 commit comments