diff --git a/Provider.php b/Provider.php index 033e256..90d4b3b 100644 --- a/Provider.php +++ b/Provider.php @@ -29,9 +29,9 @@ class Provider extends AbstractProvider * {@inheritdoc} */ protected $scopes = [ - 'openid', - 'profile', - 'email', + self::SCOPE_OPENID, + self::SCOPE_PROFILE, + self::SCOPE_EMAIL, ]; /** @@ -44,12 +44,20 @@ 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']; } /** @@ -57,7 +65,7 @@ public static function additionalConfigKeys() */ protected function getAuthUrl($state) { - return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/v1/authorize', $state); + return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/authorize', $state); } /** @@ -65,7 +73,7 @@ protected function getAuthUrl($state) */ protected function getTokenUrl() { - return $this->getOktaUrl().'/oauth2/v1/token'; + return $this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/token'; } /** @@ -73,7 +81,7 @@ protected function getTokenUrl() */ 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, ],