private function Base::authenticate in DRD Agent 4.0.x
Same name and namespace in other branches
- 8.3 src/Agent/Action/Base.php \Drupal\drd_agent\Agent\Action\Base::authenticate()
Authenticate the request or throw an exception.
Parameters
string $uuid: The uuid of the calling DRD instance.
array $args: Array of arguments.
Return value
$this
Throws
\RuntimeException
1 call to Base::authenticate()
File
- src/
Agent/ Action/ Base.php, line 304
Class
- Base
- Base class for Remote DRD Action Code.
Namespace
Drupal\drd_agent\Agent\ActionCode
private function authenticate($uuid, array $args) : self {
$auth_methods = AuthBase::getMethods($this->container);
if (!isset($auth_methods[$args['auth']]) || !$auth_methods[$args['auth']] instanceof AuthBaseInterface) {
throw new RuntimeException('Unrecognized authentication method');
}
/** @var \Drupal\drd_agent\Agent\Auth\BaseInterface $auth */
$auth = $auth_methods[$args['auth']];
if (!$auth
->validateUuid($uuid)) {
throw new RuntimeException('DRD instance not registered');
}
if (!$auth
->validate($args['authsetting'])) {
throw new RuntimeException('Not authenticated');
}
return $this;
}