Skip to content

Commit

Permalink
changed oidc_azure adapter options to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aebischer committed Oct 30, 2024
1 parent 4711da4 commit f947dd9
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/Adapter/OidcAzure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ class OidcAzure extends AbstractAdapter
*
* @var string
*/
protected $tenant = 'common';
protected $tenant;

/**
* ClientId.
*
* @var string
*/
protected $client_id = '';
protected $client_id;

/**
* Default endpoint version.
*
* @var string
*/
protected $default_end_point_version = '2.0';
protected $default_end_point_version;

/**
* Attributes.
Expand Down Expand Up @@ -148,12 +148,23 @@ protected function verifyToken(string $token): ?array
'category' => get_class($this),
]);

$options = [];

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

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

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

try {
$claims = (new \TheNetworg\OAuth2\Client\Provider\Azure([
'tenant' => $this->tenant,
'clientId' => $this->client_id,
'defaultEndPointVersion' => $this->default_end_point_version
]))->validateAccessToken($token);
$claims = (new \TheNetworg\OAuth2\Client\Provider\Azure($options))
->validateAccessToken($token);
} catch (\Exception $exception) {
$this->logger->error('cannot get claims of accessToken', [
'category' => get_class($this),
Expand Down

0 comments on commit f947dd9

Please sign in to comment.