From 101048acd1664ee5d164ea73c00cc12eccdaf282 Mon Sep 17 00:00:00 2001 From: Birler Date: Mon, 22 Nov 2021 16:02:41 +0100 Subject: [PATCH 1/2] Bug-Fix: Call parent constructor of SoapClientAuth correctly. --- src/Thybag/Auth/SoapClientAuth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Thybag/Auth/SoapClientAuth.php b/src/Thybag/Auth/SoapClientAuth.php index 4f384f5..ba33e47 100644 --- a/src/Thybag/Auth/SoapClientAuth.php +++ b/src/Thybag/Auth/SoapClientAuth.php @@ -64,7 +64,7 @@ public function __construct($wsdl, $options = NULL) { \Thybag\Auth\StreamWrapperHttpAuth::$Password = $this->Password; } - parent::SoapClient($wsdl, ($options ? $options : array())); + parent::__construct($wsdl, ($options ? $options : array())); stream_wrapper_restore('http'); if (in_array("https", $wrappers)) stream_wrapper_restore('https'); From c0b057a86bba8ebc8c9c78ee4620db36758d0a59 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 20 Jan 2023 10:04:47 +0100 Subject: [PATCH 2/2] Fixes for PHP 8.1 (#179) undefined --- composer.json | 4 ++++ src/Thybag/Auth/SharePointOnlineAuth.php | 28 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index b7b3bc2..0c0e650 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,10 @@ "email": "carl@userbag.co.uk" } ], + "require": { + "php": "^7.1 || ^8.0", + "ext-soap": "*" + }, "autoload": { "psr-0": { "Thybag" : "src/" diff --git a/src/Thybag/Auth/SharePointOnlineAuth.php b/src/Thybag/Auth/SharePointOnlineAuth.php index a99ce6d..df8900d 100644 --- a/src/Thybag/Auth/SharePointOnlineAuth.php +++ b/src/Thybag/Auth/SharePointOnlineAuth.php @@ -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); @@ -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);