Commit 37842768 authored by Bas de Nooijer's avatar Bas de Nooijer

Added endpoint authentication support to adapters

parent c4a8b6ad
......@@ -127,7 +127,10 @@ class Http extends Configurable implements AdapterInterface
}
}
$authData = $request->getAuthentication();
// Try endpoint authentication first, fallback to request for backwards compatibility
$authData = $endpoint->getAuthentication();
if(empty($authData['username'])) $authData = $request->getAuthentication();
if ( !empty($authData['username']) && !empty($authData['password'])) {
$request->addHeader('Authorization: Basic ' . base64_encode($authData['username']. ':' . $authData['password'] ));
}
......
......@@ -150,7 +150,10 @@ class PeclHttp extends Configurable implements AdapterInterface
}
}
$authData = $request->getAuthentication();
// Try endpoint authentication first, fallback to request for backwards compatibility
$authData = $endpoint->getAuthentication();
if(empty($authData['username'])) $authData = $request->getAuthentication();
if ( !empty($authData['username']) && !empty($authData['password'])) {
$headers['Authorization'] = 'Basic ' . base64_encode($authData['username']. ':' . $authData['password'] );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment