Skip to content

Commit 2649422

Browse files
authored
Merge pull request #133 from vyskocilpavel/azure_config
Allow to set some params in list of options in constructor
2 parents fc059d1 + 931914d commit 2649422

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ Usage is the same as The League's OAuth client, using `\TheNetworg\OAuth2\Client
4444
$provider = new TheNetworg\OAuth2\Client\Provider\Azure([
4545
'clientId' => '{azure-client-id}',
4646
'clientSecret' => '{azure-client-secret}',
47-
'redirectUri' => 'https://example.com/callback-url'
47+
'redirectUri' => 'https://example.com/callback-url',
48+
//Optional
49+
'scopes' => 'openid',
50+
//Optional
51+
'defaultEndPointVersion' => '2.0'
4852
]);
4953

5054
// Set to use v2 API, skip the line or set the value to Azure::ENDPOINT_VERSION_1_0 if willing to use v1 API

src/Provider/Azure.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class Azure extends AbstractProvider
1515
{
1616
const ENDPOINT_VERSION_1_0 = '1.0';
1717
const ENDPOINT_VERSION_2_0 = '2.0';
18-
18+
const ENDPOINT_VERSIONS = [self::ENDPOINT_VERSION_1_0, self::ENDPOINT_VERSION_2_0];
19+
1920
use BearerAuthorizationTrait;
2021

2122
public $urlLogin = 'https://login.microsoftonline.com/';
@@ -42,6 +43,13 @@ class Azure extends AbstractProvider
4243
public function __construct(array $options = [], array $collaborators = [])
4344
{
4445
parent::__construct($options, $collaborators);
46+
if (isset($options['scopes'])) {
47+
$this->scope = array_merge($options['scopes'], $this->scope);
48+
}
49+
if (isset($options['defaultEndPointVersion']) &&
50+
in_array($options['defaultEndPointVersion'], self::ENDPOINT_VERSIONS, true)) {
51+
$this->defaultEndPointVersion = $options['defaultEndPointVersion'];
52+
}
4553
$this->grantFactory->setGrant('jwt_bearer', new JwtBearer());
4654
}
4755

0 commit comments

Comments
 (0)