You are here

CSRFCallbackAccessCheck.php in Brightcove Video Connect 8.2

File

src/Access/CSRFCallbackAccessCheck.php
View source
<?php

namespace Drupal\brightcove\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Custom CSRF access check callback.
 */
class CSRFCallbackAccessCheck implements AccessInterface {

  /**
   * Custom access callback.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   RouterMatch object.
   *
   * @return \Drupal\Core\Access\AccessResult
   *   Access allowed only if the token is exists and did not expired.
   */
  public function access(RouteMatchInterface $route_match) {
    $token = $route_match
      ->getParameter('token');
    return AccessResult::allowedIf(\Drupal::keyValueExpirable('brightcove_callback')
      ->has($token));
  }

}

Classes

Namesort descending Description
CSRFCallbackAccessCheck Custom CSRF access check callback.