From e3ef9f23c7d2f86b3b16a174b82333cf4e2459e8 Mon Sep 17 00:00:00 2001 From: Jake Blatchford <33793364+jakeblatchford@users.noreply.github.com> Date: Tue, 12 Jan 2021 23:51:01 +0000 Subject: [PATCH] Allow Okta Auth Server ID to be empty for use with Okta OIDC app integration (#615) --- Provider.php | 16 ++++++++++++---- README.md | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Provider.php b/Provider.php index 90d4b3b..b7e3a2f 100644 --- a/Provider.php +++ b/Provider.php @@ -45,11 +45,19 @@ protected function getOktaUrl() } /** - * {@inheritdoc} + * Returns the Auth Server ID based on config option 'auth_server_id'. + * + * @return string */ protected function getAuthServerId() { - return $this->getConfig('auth_server_id', 'default'); + $auth_server_id = $this->getConfig('auth_server_id', null); + + if ($auth_server_id) { + return $auth_server_id.'/'; + } + + return ''; } /** @@ -65,7 +73,7 @@ public static function additionalConfigKeys() */ protected function getAuthUrl($state) { - return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/authorize', $state); + return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'v1/authorize', $state); } /** @@ -81,7 +89,7 @@ protected function getTokenUrl() */ protected function getUserByToken($token) { - $response = $this->getHttpClient()->get($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/userinfo', [ + $response = $this->getHttpClient()->get($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'v1/userinfo', [ 'headers' => [ 'Authorization' => 'Bearer '.$token, ], diff --git a/README.md b/README.md index ad70078..17f7188 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ Please see the [Base Installation Guide](https://socialiteproviders.com/usage/), #### Custom Auth Server -If you're using a custom auth server, pass the `auth_server_id` config option. For more information, see the [okta docs](https://developer.okta.com/docs/concepts/auth-servers/). +If you're using Okta Developer you should set `auth_server_id` config option appropriately. It should be set to "default", or to the server id of your Custom Authorization Server. + +For more information, see the [okta docs](https://developer.okta.com/docs/concepts/auth-servers/). ### Add provider event listener