5 * @package akeebaengine
6 * @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
7 * @license GNU General Public License version 3, or later
12 // Protection against direct access
13 defined('AKEEBAENGINE') || die();
16 * Base class for request signing objects.
18 abstract class Signature
21 * The request we will be signing
25 protected $request = null;
28 * Signature constructor.
30 * @param Request $request The request we will be signing
32 public function __construct(Request $request)
34 $this->request = $request;
38 * Get a signature object for the request
40 * @param Request $request The request which needs signing
41 * @param string $method The signature method, "v2" or "v4"
45 public static function getSignatureObject(Request $request, string $method = 'v2'): self
47 $className = __NAMESPACE__ . '\\Signature\\' . ucfirst($method);
49 return new $className($request);
53 * Returns the authorization header for the request
57 abstract public function getAuthorizationHeader(): string;
60 * Pre-process the request headers before we convert them to cURL-compatible format. Used by signature engines to
61 * add custom headers, e.g. x-amz-content-sha256
63 * @param array $headers The associative array of headers to process
64 * @param array $amzHeaders The associative array of amz-* headers to process
68 abstract public function preProcessHeaders(array &$headers, array &$amzHeaders): void;
71 * Get a pre-signed URL for the request. Typically used to pre-sign GET requests to objects, i.e. give shareable
72 * pre-authorized URLs for downloading files from S3.
74 * @param integer|null $lifetime Lifetime in seconds. NULL for default lifetime.
75 * @param bool $https Use HTTPS ($hostBucket should be false for SSL verification)?
77 * @return string The authenticated URL, complete with signature
79 abstract public function getAuthenticatedURL(?int $lifetime = null, bool $https = false): string;