Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional domain item configuration #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]);
Expand All @@ -32,7 +32,7 @@ foreach ($response->ReadMultiple_Result->CRMContactlist as $entity) {
print_r($entity);
}
```
__NOTE:__ NTLM Authentication string looks like `<domain>/<username>:<password>`. _All three config items are required._
__NOTE:__ NTLM Authentication string can look like `<domain>/<username>:<password>` or `<username>:<password>`. _`<username>` and `<password>` config items are required._

## Change log

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 9 additions & 4 deletions src/NTLMSoap/Common/NTLMConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NTLMConfig implements \Serializable, \Iterator
private $parameters = [];

protected $requiredParameters = [
'domain', 'username', 'password'
'username', 'password'
];

public function __construct(array $config)
Expand All @@ -24,7 +24,7 @@ public function __construct(array $config)
}

/**
* Returns a "<domain>/<username>:<password>" formated
* Returns a "<domain>/<username>:<password>" or "<username>:<password>" formatted
* string, required for NTLM Authentication headers.
*
* @author Matej Svajger <[email protected]>
Expand All @@ -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);
}

/**
Expand All @@ -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;
Expand Down