mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
oauth changes
This commit is contained in:
@@ -127,7 +127,8 @@ class ClientManager
|
||||
$client->setup(
|
||||
$userId,
|
||||
$integrationEntity,
|
||||
$externalAccountEntity
|
||||
$externalAccountEntity,
|
||||
$this
|
||||
);
|
||||
|
||||
$this->addToClientMap($client, $integrationEntity, $externalAccountEntity, $userId);
|
||||
@@ -162,7 +163,7 @@ class ClientManager
|
||||
|
||||
$oauth2Client = new \Espo\Core\ExternalAccount\OAuth2\Client();
|
||||
|
||||
$client = new $className($oauth2Client, [
|
||||
$params = [
|
||||
'endpoint' => $this->getMetadata()->get("integrations.{$integration}.params.endpoint"),
|
||||
'tokenEndpoint' => $this->getMetadata()->get("integrations.{$integration}.params.tokenEndpoint"),
|
||||
'clientId' => $integrationEntity->get('clientId'),
|
||||
@@ -172,7 +173,15 @@ class ClientManager
|
||||
'refreshToken' => $externalAccountEntity->get('refreshToken'),
|
||||
'tokenType' => $externalAccountEntity->get('tokenType'),
|
||||
'expiresAt' => $externalAccountEntity->get('expiresAt'),
|
||||
], $this);
|
||||
];
|
||||
|
||||
foreach (get_object_vars($integrationEntity->getValueMap()) as $k => $v) {
|
||||
if (array_key_exists($k, $params)) continue;
|
||||
if ($integrationEntity->hasAttribute($k)) continue;
|
||||
$params[$k] = $v;
|
||||
}
|
||||
|
||||
$client = new $className($oauth2Client, $params, $this);
|
||||
|
||||
$this->addToClientMap($client, $integrationEntity, $externalAccountEntity, $userId);
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ abstract class OAuth2Abstract implements IClient
|
||||
if ($this->getParam('expiresAt')) {
|
||||
try {
|
||||
$dt = new \DateTime($this->getParam('expiresAt'));
|
||||
$dt->modify('-' . self::ACCESS_TOKEN_EXPIRATION_MARGIN);
|
||||
$dt->modify('-' . $this::ACCESS_TOKEN_EXPIRATION_MARGIN);
|
||||
} catch (\Exception $e) {
|
||||
return;
|
||||
}
|
||||
@@ -189,11 +189,11 @@ abstract class OAuth2Abstract implements IClient
|
||||
if ($dt->format('U') <= (new \DateTime())->format('U')) {
|
||||
$GLOBALS['log']->debug("Oauth: Refreshing expired token for client {$this->clientId}.");
|
||||
|
||||
$until = microtime(true) + self::LOCK_TIMEOUT;
|
||||
$until = microtime(true) + $this::LOCK_TIMEOUT;
|
||||
|
||||
if ($this->isLocked()) {
|
||||
while (true) {
|
||||
usleep(self::LOCK_CHECK_STEP * 1000000);
|
||||
usleep($this::LOCK_CHECK_STEP * 1000000);
|
||||
|
||||
if (!$this->isLocked()) {
|
||||
$GLOBALS['log']->debug("Oauth: Waited until unlocked for client {$this->clientId}.");
|
||||
|
||||
Reference in New Issue
Block a user