Skip to content

Commit

Permalink
Merge pull request #13 from larsnovikov/proxy_auth
Browse files Browse the repository at this point in the history
Proxy auth
  • Loading branch information
camcima authored Jul 30, 2018
2 parents f56146e + bf90e81 commit f3bcae9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ $soapClient->useProxy('proxy.local', 8080, CURLPROXY_SOCKS5);

The default hostname, port and type for this methods are `localhost`, `8888` and `CURLPROXY_HTTP`, which is the default binding for Fiddler Web Debugging Proxy ([http://fiddler2.com/](http://fiddler2.com/)).

### Proxy Auth ###

If your proxy need auth, you can use this method to set proxy username and password:
```php
<?php
$soapClient->setProxyAuth('proxy_user', 'proxy_password');
```

### Authentication ###

In order to use HTTP Authentication, use SoapClient original `login` and `password` options. The cURL client will get it from there.
Expand Down
30 changes: 30 additions & 0 deletions src/Camcima/Soap/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ class Client extends \SoapClient
*/
protected $proxyPort;

/**
* Proxy User
*
* @var string
*/
protected $proxyUser;

/**
* Proxy Password
*
* @var string
*/
protected $proxyPass;

/**
* Lowercase first character of the root element name
*
Expand Down Expand Up @@ -360,6 +374,21 @@ public function useProxy($host = self::DEFAULT_PROXY_HOST, $port = self::DEFAULT
return $this;
}

/**
* Set proxy auth data
*
* @param $user
* @param $passwd
* @return $this
*/
public function setProxyAuth($user, $passwd)
{
$this->proxyUser = $user;
$this->proxyPass = $passwd;

return $this;
}

/**
* Merge Curl Options
*
Expand Down Expand Up @@ -389,6 +418,7 @@ public function getCurlOptions()
$mergedArray[CURLOPT_PROXYTYPE] = $this->proxyType;
$mergedArray[CURLOPT_PROXY] = $this->proxyHost;
$mergedArray[CURLOPT_PROXYPORT] = $proxyPort;
$mergedArray[CURLOPT_PROXYUSERPWD] = $this->proxyUser . ':' . $this->proxyPass;
}

return $mergedArray;
Expand Down

0 comments on commit f3bcae9

Please sign in to comment.