Skip to content

Commit

Permalink
Merge pull request #180 from thybag/develop
Browse files Browse the repository at this point in the history
Community fixes to master
  • Loading branch information
thybag authored Jan 20, 2023
2 parents 6f03a95 + c0b057a commit cb3479d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"email": "[email protected]"
}
],
"require": {
"php": "^7.1 || ^8.0",
"ext-soap": "*"
},
"autoload": {
"psr-0": {
"Thybag" : "src/"
Expand Down
28 changes: 21 additions & 7 deletions src/Thybag/Auth/SharePointOnlineAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,26 @@ class SharePointOnlineAuth extends \SoapClient {
// Authentication cookies
private $authCookies = false;

private $login;
private $password;

/**
* Store username+password ourselves since they are private in
* PHP 8.1's SoapClient.
*/
public function __construct($wsdl, $options) {
parent::__construct($wsdl, $options);

if (isset($options['login'])) {
$this->login = $options['login'];
}
if (isset($options['password'])) {
$this->password = $options['password'];
}
}

// Override do request method
public function __doRequest($request, $location, $action, $version, $one_way = false) {
public function __doRequest($request, $location, $action, $version, $one_way = false): ?string {

// Authenticate with SP online in order to get required authentication cookies
if (!$this->authCookies) $this->configureAuthCookies($location);
Expand Down Expand Up @@ -73,17 +91,13 @@ protected function configureAuthCookies($location) {
$location = parse_url($location);
$endpoint = 'https://'.$location['host'];

// get username & password
$login = $this->{'_login'};
$password = $this->{'_password'};

// Create XML security token request
$xml = $this->generateSecurityToken($login, $password, $endpoint);
$xml = $this->generateSecurityToken($this->login, $this->password, $endpoint);

// Send request and grab returned xml
$result = $this->authCurl("https://login.microsoftonline.com/extSTS.srf", $xml);


// Extract security token from XML
$xml = new \DOMDocument();
$xml->loadXML($result);
Expand Down

0 comments on commit cb3479d

Please sign in to comment.