Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
37842768
Commit
37842768
authored
Jan 22, 2013
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added endpoint authentication support to adapters
parent
c4a8b6ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
library/Solarium/Core/Client/Adapter/Http.php
library/Solarium/Core/Client/Adapter/Http.php
+4
-1
library/Solarium/Core/Client/Adapter/PeclHttp.php
library/Solarium/Core/Client/Adapter/PeclHttp.php
+4
-1
No files found.
library/Solarium/Core/Client/Adapter/Http.php
View file @
37842768
...
@@ -127,7 +127,10 @@ class Http extends Configurable implements AdapterInterface
...
@@ -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'
]))
{
if
(
!
empty
(
$authData
[
'username'
])
&&
!
empty
(
$authData
[
'password'
]))
{
$request
->
addHeader
(
'Authorization: Basic '
.
base64_encode
(
$authData
[
'username'
]
.
':'
.
$authData
[
'password'
]
));
$request
->
addHeader
(
'Authorization: Basic '
.
base64_encode
(
$authData
[
'username'
]
.
':'
.
$authData
[
'password'
]
));
}
}
...
...
library/Solarium/Core/Client/Adapter/PeclHttp.php
View file @
37842768
...
@@ -150,7 +150,10 @@ class PeclHttp extends Configurable implements AdapterInterface
...
@@ -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'
]))
{
if
(
!
empty
(
$authData
[
'username'
])
&&
!
empty
(
$authData
[
'password'
]))
{
$headers
[
'Authorization'
]
=
'Basic '
.
base64_encode
(
$authData
[
'username'
]
.
':'
.
$authData
[
'password'
]
);
$headers
[
'Authorization'
]
=
'Basic '
.
base64_encode
(
$authData
[
'username'
]
.
':'
.
$authData
[
'password'
]
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment