Base.php in DRD Agent 4.0.x
File
src/Agent/Auth/Base.php
View source
<?php
namespace Drupal\drd_agent\Agent\Auth;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\State\StateInterface;
use Drupal\user\UserAuthInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class Base implements BaseInterface {
protected $storedSettings;
protected $currentUser;
protected $state;
protected $userAuth;
public function __construct(AccountInterface $current_User, StateInterface $state, UserAuthInterface $user_auth) {
$this->currentUser = $current_User;
$this->state = $state;
$this->userAuth = $user_auth;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('current_user'), $container
->get('state'), $container
->get('user.auth'));
}
public static function getMethods(ContainerInterface $container) : array {
$methods = array(
'username_password' => 'UsernamePassword',
'shared_secret' => 'SharedSecret',
);
foreach ($methods as $key => $class) {
$classname = "\\Drupal\\drd_agent\\Agent\\Auth\\{$class}";
$methods[$key] = $classname::create($container);
}
return $methods;
}
public final function validateUuid($uuid) : bool {
$authorised = $this->state
->get('drd_agent.authorised', []);
if (empty($authorised[$uuid])) {
return FALSE;
}
$this->storedSettings = (array) $authorised[$uuid]['authsetting'];
return TRUE;
}
}
Classes
Name |
Description |
Base |
Base class for Remote DRD Auth Methods. |