Skip to content

Commit

Permalink
Allow Okta Auth Server ID to be empty for use with Okta OIDC app inte…
Browse files Browse the repository at this point in the history
…gration (#615)
  • Loading branch information
jakeblatchford authored Jan 12, 2021
1 parent 60f88b8 commit e3ef9f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 12 additions & 4 deletions Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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,
],
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e3ef9f2

Please sign in to comment.