diff --git a/.htaccess b/.htaccess index 39aec231fc..f9bd54ac74 100755 --- a/.htaccess +++ b/.htaccess @@ -4,5 +4,7 @@ RedirectMatch 403 \.config$ RewriteEngine On +RewriteRule .* - [E=HTTP_ESPO_CGI_AUTH:%{HTTP:Authorization}] + RewriteRule reset/?$ reset.html [QSA,L] \ No newline at end of file diff --git a/api/v1/.htaccess b/api/v1/.htaccess index b5f9c3c4a4..c1d824da79 100755 --- a/api/v1/.htaccess +++ b/api/v1/.htaccess @@ -6,5 +6,7 @@ RewriteEngine On # # RewriteBase / +RewriteRule .* - [E=HTTP_ESPO_CGI_AUTH:%{HTTP:Authorization}] + RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] \ No newline at end of file diff --git a/application/Espo/Core/Utils/Api/Auth.php b/application/Espo/Core/Utils/Api/Auth.php index 4f053e77c9..5394fa16f1 100644 --- a/application/Espo/Core/Utils/Api/Auth.php +++ b/application/Espo/Core/Utils/Api/Auth.php @@ -51,9 +51,12 @@ class Auth extends \Slim\Middleware $espoAuth = $req->headers('HTTP_ESPO_AUTHORIZATION'); if (isset($espoAuth)) { - $credentials = explode(':', base64_decode($espoAuth)); - $authUsername = $credentials[0]; - $authPassword = $credentials[1]; + list($authUsername, $authPassword) = explode(':', base64_decode($espoAuth)); + } + + $espoCgiAuth = $req->headers('HTTP_ESPO_CGI_AUTH'); + if ( !isset($authUsername) && !isset($authPassword) && isset($espoCgiAuth) ) { + list($authUsername, $authPassword) = explode(':' , base64_decode(substr($espoCgiAuth, 6))); } if (is_null($this->authRequired)) {