You are here

public function DenyCas::check in CAS 2.x

Same name and namespace in other branches
  1. 8 src/PageCache/DenyCas.php \Drupal\cas\PageCache\DenyCas::check()

Determines whether it is save to store a page in the cache.

Parameters

\Symfony\Component\HttpFoundation\Response $response: The response which is about to be sent to the client.

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

string|null Either static::DENY or NULL. Calling code may attempt to store a page in the cache unless static::DENY is returned. Returns NULL if the policy policy is not specified for the given response.

Overrides ResponsePolicyInterface::check

File

src/PageCache/DenyCas.php, line 50

Class

DenyCas
Ensures pages configured with gateway authentication are not cached.

Namespace

Drupal\cas\PageCache

Code

public function check(Response $response, Request $request) {
  $config = $this->configFactory
    ->get('cas.settings');
  if ($config
    ->get('gateway.enabled') && $config
    ->get('gateway.method') === CasHelper::GATEWAY_SERVER_SIDE) {

    // 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;
}