can add basic auth credentials to load image file from protected shop

# Conflicts:
#	Application/views/admin_smarty/de/pdfdocuments_lang.php
#	Application/views/admin_smarty/en/pdfdocuments_lang.php
This commit is contained in:
2025-05-14 13:27:29 +02:00
parent a5c618c34f
commit 4a538bcec3
4 changed files with 53 additions and 0 deletions

View File

@ -206,6 +206,27 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
self::$_blIsAdmin = $blCurrentRenderFromAdmin;
$content = $this->addBasicAuth($content);
return $content;
}
protected function addBasicAuth($content)
{
$username = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthUserName'));
$password = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthPassword'));
if ($username && $password) {
$shopUrl = parse_url( Registry::getConfig()->getShopCurrentUrl() );
$pattern = '/(["|\'])'.
'(' . preg_quote( $shopUrl['scheme'], '/' ) . ':\/\/)'.
'(' . preg_quote( $shopUrl['host'], '/' ) . '.*?)'.
'\1/m';
$replace = "$1$2" . urlencode($username). ":" . urlencode($password) . "@$3$1";
$content = preg_replace( $pattern, $replace, $content );
}
return $content;
}