Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
extensions.typo3.org
extensions.typo3.org
Commits
10a9ac47
Commit
10a9ac47
authored
Aug 06, 2017
by
Thomas Löffler
Browse files
Adds possibility to use HTTP auth for SOAP requests
parent
82f2078c
Pipeline
#1824
passed with stages
in 3 minutes and 35 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
html/typo3conf/ext/ter_fe2/Classes/Controller/AbstractTerBasedController.php
View file @
10a9ac47
...
...
@@ -118,7 +118,7 @@ abstract class AbstractTerBasedController extends \T3o\TerFe2\Controller\Abstrac
// Create connection
$wsdl
=
$this
->
terSettings
[
'wsdl'
];
return
$this
->
objectManager
->
get
(
\
T3o\TerFe2\Service\Ter
::
class
,
$wsdl
,
$this
->
terAccount
[
'username'
],
$this
->
terAccount
[
'password'
]);
return
$this
->
objectManager
->
get
(
\
T3o\TerFe2\Service\Ter
::
class
,
$wsdl
,
$this
->
terAccount
[
'username'
],
$this
->
terAccount
[
'password'
]
,
$this
->
terAccount
[
'httpAuth'
]
);
}
}
html/typo3conf/ext/ter_fe2/Classes/Provider/SoapProvider.php
View file @
10a9ac47
...
...
@@ -70,8 +70,10 @@ class SoapProvider extends \T3o\TerFe2\Provider\AbstractProvider
$username
=
(
empty
(
$this
->
configuration
[
'username'
])
?
$this
->
configuration
[
'username'
]
:
''
);
$password
=
(
empty
(
$this
->
configuration
[
'password'
])
?
$this
->
configuration
[
'password'
]
:
''
);
$httpAuth
[
'login'
]
=
$this
->
configuration
[
'httpAuth'
][
'login'
]
?:
''
;
$httpAuth
[
'password'
]
=
$this
->
configuration
[
'httpAuth'
][
'password'
]
?:
''
;
$this
->
soapService
=
$this
->
objectManager
->
get
(
\
T3o\TerFe2\Service\Soap
::
class
);
$this
->
soapService
->
connect
(
$this
->
configuration
[
'wsdlUrl'
],
$username
,
$password
);
$this
->
soapService
->
connect
(
$this
->
configuration
[
'wsdlUrl'
],
$username
,
$password
,
$httpAuth
);
// Set getExtensionsFunc
if
(
!
empty
(
$this
->
configuration
[
'getExtensionsFunc'
]))
{
...
...
html/typo3conf/ext/ter_fe2/Classes/Service/Soap.php
View file @
10a9ac47
...
...
@@ -41,6 +41,10 @@ class Soap implements \TYPO3\CMS\Core\SingletonInterface
*/
protected
$authenticationHeader
;
/**
* @var array
*/
protected
$httpAuth
=
[];
protected
$wsdlUrl
,
...
...
@@ -55,10 +59,11 @@ class Soap implements \TYPO3\CMS\Core\SingletonInterface
* @param string $username Login with this username
* @param string $password Login with this password
* @param boolean $returnExceptions Return exception in case of errors
* @param array $httpAuth HTTP Authentication if needed
* @return \SoapClient
* @throws \Exception
*/
public
function
connect
(
$wsdlUrl
,
$username
=
''
,
$password
=
''
,
$returnExceptions
=
FALSE
)
public
function
connect
(
$wsdlUrl
,
$username
=
''
,
$password
=
''
,
$returnExceptions
=
FALSE
,
array
$httpAuth
=
[]
)
{
if
(
empty
(
$wsdlUrl
))
{
...
...
@@ -73,6 +78,7 @@ class Soap implements \TYPO3\CMS\Core\SingletonInterface
$this
->
username
=
$username
;
$this
->
password
=
$password
;
$this
->
returnExceptions
=
$returnExceptions
;
$this
->
httpAuth
=
$httpAuth
;
return
$this
->
resetConnection
();
}
...
...
@@ -93,12 +99,21 @@ class Soap implements \TYPO3\CMS\Core\SingletonInterface
public
function
resetConnection
()
{
// Create connection
$arrContextOptions
=
stream_context_create
([
'ssl'
=>
[
'verify_peer'
=>
false
,
'verify_peer_name'
=>
false
,
],
]);
echo
file_get_contents
(
$this
->
wsdlUrl
,
false
,
$arrContextOptions
);
$this
->
soapConnection
=
new
\
SoapClient
(
$this
->
wsdlUrl
,
array
(
'trace'
=>
1
,
'exceptions'
=>
(
bool
)
$this
->
returnExceptions
,
'encoding'
=>
'UTF-8'
,
'soap_version'
=>
SOAP_1_2
,
'cache_wsdl'
=>
WSDL_CACHE_NONE
,
'login'
=>
$this
->
httpAuth
[
'login'
]
?:
''
,
'password'
=>
$this
->
httpAuth
[
'password'
]
?:
''
));
// Get authentication header
...
...
@@ -167,13 +182,6 @@ class Soap implements \TYPO3\CMS\Core\SingletonInterface
public
function
__call
(
$methodName
,
array
$params
=
array
())
{
$this
->
resetConnection
();
// // Check for existing connection
// if (empty($this->soapConnection)) {
// throw new \Exception('Create SOAP connection first');
// }
// Call given method
$response
=
$this
->
soapConnection
->
__soapCall
(
$methodName
,
...
...
html/typo3conf/ext/ter_fe2/Classes/Service/Ter.php
View file @
10a9ac47
...
...
@@ -55,9 +55,13 @@ class Ter
/**
* Load TER connection
*
* @param string $wsdlUrl
* @param string $username
* @param string $password
* @param array $httpAuth
* @return void
*/
public
function
__construct
(
$wsdlUrl
,
$username
,
$password
)
public
function
__construct
(
$wsdlUrl
,
$username
,
$password
,
array
$httpAuth
=
[]
)
{
$this
->
wsdlUrl
=
$wsdlUrl
;
$this
->
userData
=
array
(
...
...
@@ -66,7 +70,7 @@ class Ter
);
$objectManager
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Extbase\Object\ObjectManager
::
class
);
$this
->
soapService
=
$objectManager
->
get
(
\
T3o\TerFe2\Service\Soap
::
class
);
$this
->
soapService
->
connect
(
$this
->
wsdlUrl
,
''
,
''
,
TRUE
);
$this
->
soapService
->
connect
(
$this
->
wsdlUrl
,
''
,
''
,
TRUE
,
$httpAuth
);
}
...
...
html/typo3conf/ext/ter_fe2/Configuration/TypoScript/Default/constants.txt
View file @
10a9ac47
...
...
@@ -51,6 +51,14 @@ plugin.tx_terfe2 {
# cat=TER Frontend/settings/2020; type=string; label=TER Password: Password to connect TER server
password =
httpAuth {
# cat=TER Frontend/settings/2030; type=string; label=HTTP Auth login: Login for HTTP Auth
login =
# cat=TER Frontend/settings/2040; type=string; label=HTTP Auth password: Password for HTTP Auth
password =
}
}
smallImage {
...
...
html/typo3conf/ext/ter_fe2/Configuration/TypoScript/Default/setup.txt
View file @
10a9ac47
...
...
@@ -24,6 +24,10 @@ plugin.tx_terfe2 {
wsdl = {$plugin.tx_terfe2.settings.terConnection.wsdl}
username = {$plugin.tx_terfe2.settings.terConnection.username}
password = {$plugin.tx_terfe2.settings.terConnection.password}
httpAuth {
login = {$plugin.tx_terfe2.settings.terConnection.httpAuth.login}
password = {$plugin.tx_terfe2.settings.terConnection.httpAuth.password}
}
}
smallImage {
...
...
Write
Preview
Supports
Markdown
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