Skip to content
Snippets Groups Projects
Commit 53b5c485 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3398042 by danielspeicher, jurgenhaas: Coding standards for PHP Stan Level 6 and CS

parent c7a0f104
No related branches found
Tags 8.x-1.0
No related merge requests found
Pipeline #42289 passed
......@@ -28,6 +28,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class Base implements BaseInterface, ContainerInjectionInterface {
// The following 3 constants are required by DRD to build and verify the auth
// method in the client handshake.
// @see \Drupal\drd_pi\DrdPiAccountInterface::getAuthorizationMethod
public const SEC_AUTH_ACQUIA = 'Acquia';
public const SEC_AUTH_PANTHEON = 'Pantheon';
public const SEC_AUTH_PLATFORMSH = 'PlatformSH';
/**
* The debug mode.
*
......@@ -45,9 +52,9 @@ class Base implements BaseInterface, ContainerInjectionInterface {
/**
* Crypt object for this DRD request.
*
* @var \Drupal\drd_agent\Crypt\BaseMethodInterface
* @var \Drupal\drd_agent\Crypt\BaseMethodInterface|bool
*/
protected BaseMethodInterface $crypt;
protected BaseMethodInterface|bool $crypt;
/**
* The account switcher.
......@@ -241,7 +248,7 @@ class Base implements BaseInterface, ContainerInjectionInterface {
throw new \RuntimeException('Can not read input');
}
$input = json_decode(base64_decode($raw_input), TRUE);
$input = json_decode(base64_decode($raw_input), TRUE, 512, JSON_THROW_ON_ERROR);
if (!is_array($input) || empty($input)) {
throw new \RuntimeException('Input is empty');
}
......@@ -324,7 +331,7 @@ class Base implements BaseInterface, ContainerInjectionInterface {
$actionObject = $classname::create($this->container);
$actionObject->init($this->crypt, $this->arguments, $this->debugMode);
}
catch (\Exception $ex) {
catch (\Exception) {
$this->watchdog('Not yet implemented: ' . $action, [], 3);
header('HTTP/1.1 403 Not found');
print 'Not yet implemented';
......@@ -484,18 +491,18 @@ class Base implements BaseInterface, ContainerInjectionInterface {
* {@inheritdoc}
*/
public function ott(string $ott, string $remoteSetupToken): bool {
$ott = $this->state->get('drd_agent.ott', FALSE);
if (!$ott) {
$storedOtt = $this->state->get('drd_agent.ott', FALSE);
if (!$storedOtt) {
$this->watchdog('No OTT available', [], RfcLogLevel::ERROR);
return FALSE;
}
$this->state->delete('drd_agent.ott');
if (empty($ott['expires']) || $ott['expires'] < $this->time->getRequestTime()) {
if (empty($storedOtt['expires']) || $storedOtt['expires'] < $this->time->getRequestTime()) {
$this->watchdog('OTT expired', [], RfcLogLevel::ERROR);
return FALSE;
}
if (empty($ott['token']) || $ott['token'] !== $ott) {
$this->watchdog('Token missmatch: :local / :remote', [':local' => $ott['token'], ':remote' => $ott], RfcLogLevel::ERROR);
if (empty($storedOtt['token']) || $storedOtt['token'] !== $ott) {
$this->watchdog('Token missmatch: :local / :remote', [':local' => $storedOtt['token'], ':remote' => $ott], RfcLogLevel::ERROR);
return FALSE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment