Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/DeployActions/DockerActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ public function resolveExAppUrl(
} else {
$exAppHost = $appId;
}
if (isset($deployConfig['haproxy_password']) && $deployConfig['haproxy_password'] !== '') {
if ($protocol == 'https' && isset($deployConfig['haproxy_password']) && $deployConfig['haproxy_password'] !== '') {
// we only set haproxy auth for remote installations, when all requests come through HaProxy.
$auth = [self::APP_API_HAPROXY_USER, $deployConfig['haproxy_password']];
}
return sprintf('%s://%s:%s', $protocol, $exAppHost, $port);
Expand Down
20 changes: 20 additions & 0 deletions lib/Service/AppAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private function prepareRequestToExApp(
$options['http_errors'] = false; // do not throw exceptions on 4xx and 5xx responses
if (!empty($auth)) {
$options['auth'] = $auth;
$options['headers'] = $this->swapAuthorizationHeader($options['headers']);
}
if (!isset($options['timeout'])) {
$options['timeout'] = 3;
Expand Down Expand Up @@ -221,6 +222,7 @@ private function prepareRequestToExApp2(
$options['http_errors'] = false; // do not throw exceptions on 4xx and 5xx responses
if (!empty($auth)) {
$options['auth'] = $auth;
$options['headers'] = $this->swapAuthorizationHeader($options['headers']);
}
if (!isset($options['timeout'])) {
$options['timeout'] = 3;
Expand All @@ -237,6 +239,24 @@ private function prepareRequestToExApp2(
return ['url' => $url, 'options' => $options];
}

/**
* This is required for AppAPI Docker Socket Proxy, as the Basic Auth is already in use by HaProxy,
* and the incoming request's Authorization is replaced with X-Original-Authorization header
* after HaProxy authenticated.
*
* @since AppAPI 3.0.0
*/

private function swapAuthorizationHeader(array $headers): array {
foreach ($headers as $key => $value) {
if (strtoupper($key) === 'AUTHORIZATION') {
$headers['X-Original-Authorization'] = $value;
break;
}
}
return $headers;
}

private function getUriEncodedParams(array $params): string {
$paramsContent = '';
foreach ($params as $key => $value) {
Expand Down