diff --git a/README.md b/README.md index 810c098..b98ca36 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ $ composer require matejsvajger/ntlm-soap-client ``` php $url = 'URL_TO_WEBSERVICE_WSDL'; $config = new matejsvajger\NTLMSoap\Common\NTLMConfig([ - 'domain' => 'domain', + 'domain' => 'domain', // Can be omitted 'username' => 'username', 'password' => 'password' ]); @@ -32,7 +32,7 @@ foreach ($response->ReadMultiple_Result->CRMContactlist as $entity) { print_r($entity); } ``` -__NOTE:__ NTLM Authentication string looks like `/:`. _All three config items are required._ +__NOTE:__ NTLM Authentication string can look like `/:` or `:`. _`` and `` config items are required._ ## Change log diff --git a/composer.json b/composer.json index f170302..235ae67 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ } ], "require": { - "php": "~5.6|~7.0", - "symfony/console": "^3.1" + "php": "~5.6|~7.0|~8.0", + "symfony/console": "^3.1||^4.0||^5.0||^6.0" }, "require-dev": { "phpunit/phpunit" : "~4.0||~5.0", diff --git a/src/NTLMSoap/Common/NTLMConfig.php b/src/NTLMSoap/Common/NTLMConfig.php index 62b148a..ea349d1 100644 --- a/src/NTLMSoap/Common/NTLMConfig.php +++ b/src/NTLMSoap/Common/NTLMConfig.php @@ -9,7 +9,7 @@ class NTLMConfig implements \Serializable, \Iterator private $parameters = []; protected $requiredParameters = [ - 'domain', 'username', 'password' + 'username', 'password' ]; public function __construct(array $config) @@ -24,7 +24,7 @@ public function __construct(array $config) } /** - * Returns a "/:" formated + * Returns a "/:" or ":" formatted * string, required for NTLM Authentication headers. * * @author Matej Svajger @@ -35,11 +35,11 @@ public function __construct(array $config) */ public static function getAuthString() { - $domain = $GLOBALS['NTLMClientDomain']; + $domain = isset($GLOBALS['NTLMClientDomain']) && !empty($GLOBALS['NTLMClientDomain']) ? $GLOBALS['NTLMClientDomain'] : ''; $username = $GLOBALS['NTLMClientUsername']; $password = $GLOBALS['NTLMClientPassword']; - return "{$domain}/{$username}:{$password}"; + return sprintf('%s%s:%s', $domain ? $domain.'/' : '', $username, $password); } /** @@ -61,6 +61,11 @@ protected function assertParametersAreValid(array $parameters) } } + public function __isset($param) + { + return isset($this->parameters[$param]); + } + public function __set($param, $value) { $this->parameters[$param] = $value;