public function Base::ott in DRD Agent 8.3
Same name and namespace in other branches
- 4.0.x src/Agent/Action/Base.php \Drupal\drd_agent\Agent\Action\Base::ott()
Validate a one-time-token.
Parameters
string $ott: Token to be validated.
string $remoteSetupToken: Base64 encoded RemoteSetupToken from DRD.
Return value
bool TRUE if token is valid and configuration succeeded, FALSE otherwise.
Overrides BaseInterface::ott
File
- src/
Agent/ Action/ Base.php, line 465
Class
- Base
- Base class for Remote DRD Action Code.
Namespace
Drupal\drd_agent\Agent\ActionCode
public function ott($token, $remoteSetupToken) : bool {
$config = $this->configFactory
->getEditable('drd_agent.settings');
$ott = $config
->get('ott');
if (!$ott) {
$this
->watchdog('No OTT available', [], LogLevel::ERROR);
return FALSE;
}
$config
->clear('ott');
if (empty($ott['expires']) || $ott['expires'] < $this->time
->getRequestTime()) {
$this
->watchdog('OTT expired', [], LogLevel::ERROR);
return FALSE;
}
if (empty($ott['token']) || $ott['token'] !== $token) {
$this
->watchdog('Token missmatch: :local / :remote', [
':local' => $ott['token'],
':remote' => $token,
], LogLevel::ERROR);
return FALSE;
}
/* @var \Drupal\drd_agent\Setup $service */
$service = $this->container
->get('drd_agent.setup');
$service
->setRemoteSetupToken($remoteSetupToken)
->execute();
$this
->watchdog('OTT config completed', [], LogLevel::INFO);
return TRUE;
}