http-signature fixes from upstream - preserve (request-target) from original gateway request prior to redirection

This commit is contained in:
Mike Macgirvin 2024-07-30 06:25:58 +10:00
parent c36de06026
commit 75148b984f
4 changed files with 5 additions and 4 deletions

View file

@ -166,7 +166,7 @@ class App {
private static $widgets = []; // widgets for this page
public static $config = []; // config cache
public static $icon = '';
public static $originalRequest;
public static $override_intltext_templates = [];
public static $override_markup_templates = [];
public static $override_templateroot = null;

View file

@ -62,7 +62,7 @@ function as_return_and_die($obj, $channel, $contextType = null, $signObject = tr
logger('data: ' . jindent($json), LOGGER_DATA);
$headers['Date'] = Time::convert('UTC', 'UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T');
$headers['Digest'] = HTTPSig::generate_digest_header($json);
$headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
$headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . (App::$originalRequest ?? $_SERVER['REQUEST_URI']);
$h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], Channel::keyId($channel));
HTTPSig::set_headers($h);

View file

@ -16,7 +16,7 @@ class Apgateway extends Controller
public function init()
{
App::$originalRequest = '/' . $_REQUEST['req'];
// Concatenate path components starting with argv(1)
// to isolate the DID URL.
$url = null;

View file

@ -2,6 +2,7 @@
namespace Code\Web;
use App;
use Code\Lib\ActorId;
use Code\Lib\Time;
use DateTime;
@ -67,7 +68,7 @@ class HTTPSig
$headers['(request-target)'] = $data['request_target'];
} else {
$headers = [];
$headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
$headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . (App::$originalRequest ?? $_SERVER['REQUEST_URI']);
$headers['content-type'] = $_SERVER['CONTENT_TYPE'];
$headers['content-length'] = $_SERVER['CONTENT_LENGTH'];