You are here

class DenyCas in CAS 8

Same name and namespace in other branches
  1. 2.x src/PageCache/DenyCas.php \Drupal\cas\PageCache\DenyCas

Ensures pages configured with gateway authentication are not cached.

The logic we use to determine if a user should be redirected to gateway auth is currently not compatible with page caching.

Hierarchy

Expanded class hierarchy of DenyCas

1 string reference to 'DenyCas'
cas.services.yml in ./cas.services.yml
cas.services.yml
1 service uses DenyCas
cas.page_cache_response_policy.deny_cas in ./cas.services.yml
Drupal\cas\PageCache\DenyCas

File

src/PageCache/DenyCas.php, line 18

Namespace

Drupal\cas\PageCache
View source
class DenyCas implements ResponsePolicyInterface {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Condition manager.
   *
   * @var \Drupal\Core\Executable\ExecutableManagerInterface
   */
  protected $conditionManager;

  /**
   * Constructs a response policy for disabling cache on specific CAS paths.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The current route match.
   * @param \Drupal\Core\Executable\ExecutableManagerInterface $condition_manager
   *   The condition manager.
   */
  public function __construct(ConfigFactoryInterface $config_factory, ExecutableManagerInterface $condition_manager) {
    $this->configFactory = $config_factory;
    $this->conditionManager = $condition_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function check(Response $response, Request $request) {
    $config = $this->configFactory
      ->get('cas.settings');
    if ($config
      ->get('gateway.check_frequency') !== CasHelper::CHECK_NEVER) {

      // User can indicate specific paths to enable (or disable) gateway mode.
      $condition = $this->conditionManager
        ->createInstance('request_path');
      $condition
        ->setConfiguration($config
        ->get('gateway.paths'));
      if ($this->conditionManager
        ->execute($condition)) {
        return static::DENY;
      }
    }
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DenyCas::$conditionManager protected property Condition manager.
DenyCas::$configFactory protected property The config factory.
DenyCas::check public function Determines whether it is save to store a page in the cache. Overrides ResponsePolicyInterface::check
DenyCas::__construct public function Constructs a response policy for disabling cache on specific CAS paths.
ResponsePolicyInterface::DENY constant Deny storage of a page in the cache.