Skip to content

Commit

Permalink
Instance url is no longer required for JWT auth
Browse files Browse the repository at this point in the history
  • Loading branch information
omniphx committed Mar 23, 2024
1 parent f1d220b commit e1906c0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Omniphx/Forrest/Authentications/OAuthJWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Firebase\JWT\JWT;
use Omniphx\Forrest\Client as BaseAuthentication;
use Omniphx\Forrest\Interfaces\AuthenticationInterface;
use Omniphx\Forrest\Exceptions\MissingTokenException;

class OAuthJWT extends BaseAuthentication implements AuthenticationInterface
{
Expand All @@ -21,12 +22,21 @@ public static function getJWT($iss, $aud, $sub, $privateKey)
return JWT::encode($payload, $privateKey, 'RS256');
}

private function getDefaultInstanceURL()
{
if (isset($this->settings['instanceURL']) && !empty($this->settings['instanceURL'])) {
return $this->settings['instanceURL'];
} else {
return $this->credentials['loginURL'];
}
}

public function authenticate($fullInstanceUrl = null)
{
$loginUrl = $this->credentials['loginURL'];
$fullInstanceUrl = $fullInstanceUrl ?? $loginUrl . '/services/oauth2/token';
$fullInstanceUrl = $fullInstanceUrl ?? $this->getDefaultInstanceURL() . '/services/oauth2/token';

$consumerKey = $this->credentials['consumerKey'];
$loginUrl = $this->credentials['loginURL'];
$username = $this->credentials['username'];
$privateKey = $this->credentials['privateKey'];

Expand Down

0 comments on commit e1906c0

Please sign in to comment.