Skip to content

Commit

Permalink
add okta custom auth server (#520)
Browse files Browse the repository at this point in the history
Co-authored-by: atymic <[email protected]>
  • Loading branch information
kjiang14 and atymic authored Oct 25, 2020
1 parent 8ade52b commit a0271cd
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class Provider extends AbstractProvider
* {@inheritdoc}
*/
protected $scopes = [
'openid',
'profile',
'email',
self::SCOPE_OPENID,
self::SCOPE_PROFILE,
self::SCOPE_EMAIL,
];

/**
Expand All @@ -44,36 +44,44 @@ protected function getOktaUrl()
return $this->getConfig('base_url');
}

/**
* {@inheritdoc}
*/
protected function getAuthServerId()
{
return $this->getConfig('auth_server_id', 'default');
}

/**
* {@inheritdoc}
*/
public static function additionalConfigKeys()
{
return ['base_url'];
return ['base_url', 'auth_server_id'];
}

/**
* {@inheritdoc}
*/
protected function getAuthUrl($state)
{
return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/v1/authorize', $state);
return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/authorize', $state);
}

/**
* {@inheritdoc}
*/
protected function getTokenUrl()
{
return $this->getOktaUrl().'/oauth2/v1/token';
return $this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/token';
}

/**
* {@inheritdoc}
*/
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get($this->getOktaUrl().'/oauth2/v1/userinfo', [
$response = $this->getHttpClient()->get($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/userinfo', [
'headers' => [
'Authorization' => 'Bearer '.$token,
],
Expand Down

0 comments on commit a0271cd

Please sign in to comment.