TheNetworg / oauth2-azure

Azure AD provider for the OAuth 2.0 Client.
https://packagist.org/packages/thenetworg/oauth2-azure
MIT License
230 stars 109 forks source link

Allow to set some params in list of options in constructor #133

Closed vyskocilpavel closed 3 years ago

vyskocilpavel commented 3 years ago

Hi, We are using simplesamlphp module(https://github.com/cirrusidentity/simplesamlphp-module-authoauth2) with some oauth2-clients. We want to use your client for AzureAD, but we need the possibility to set scopes and defaultEndPointVersion from the 'options' field in the constructor.

This PR allows setting the 'scopes' and 'defaultEndPointVersion' from the constructor.

Thanks for the review.

hajekj commented 3 years ago

Looks pretty good to me, thanks for the PR! Will release this as v2.0.1 since it is not a breaking change.

hajekj commented 3 years ago

Done: https://github.com/TheNetworg/oauth2-azure/releases/tag/v2.0.1

decomplexity commented 3 years ago

If PR'er wants to use 2.0.1 with the Microsoft Graph REST API instead of the older Azure AD Graph, note that the following changes appear needed in Azure.php 2.0.1 (vide my issue #127):

Line 35:

public $urlAPI = 'https://graph.windows.net/';

=>

public $urlAPI = 'https://graph.microsoft.com/';

Line 39:

public $API_VERSION = '1.6';

=>

public $API_VERSION = '1.0';

line 214

if (false !== strpos($this->urlAPI, 'graph.windows.net')) {

=>

if (false !== strpos($this->urlAPI, ‘graph.microsoft.com’)) {

and defaultEndPointVersion needs overriding to ENDPOINT_VERSION_2_0;

hajekj commented 3 years ago

I will see if I can get this fixed. Would be great if people used https://github.com/microsoftgraph/msgraph-sdk-php instead for calling Microsoft Graph.

decomplexity commented 3 years ago

Tnx Jan. We already use the MSgraph SDK for some new apps. However, most of our websites use the 'Send_Oauth2' wrapper that we developed for PHPMailer. This wrapper supports the numerous ‘email’ instances typical websites need (Contact page, purchase emails, notifications from Paypal IPN and so on) with a single repository of clientID, clientSecret and refresh token, and supports both MSFT 365 and Gmail, and Basic Auth as well as Oauth2. The MSFT 365 ‘provider’ – which uses Graph V1 and V2 AUTHN/Z endpoints is your own excellent one – for which we are very grateful! - with the overrides (above).