You are here

class DisallowKeyAuthRequests in Key auth 8

Cache policy for pages served from key auth.

This policy disallows caching of requests that use key_auth for security reasons. Otherwise responses for authenticated requests can get into the page cache and could be delivered to unprivileged users.

Hierarchy

Expanded class hierarchy of DisallowKeyAuthRequests

1 string reference to 'DisallowKeyAuthRequests'
key_auth.services.yml in ./key_auth.services.yml
key_auth.services.yml
1 service uses DisallowKeyAuthRequests
key_auth.page_cache_request_policy.disallow_key_auth_requests in ./key_auth.services.yml
Drupal\key_auth\PageCache\DisallowKeyAuthRequests

File

src/PageCache/DisallowKeyAuthRequests.php, line 16

Namespace

Drupal\key_auth\PageCache
View source
class DisallowKeyAuthRequests implements RequestPolicyInterface {

  /**
   * The key auth service.
   *
   * @var \Drupal\key_auth\KeyAuthInterface
   */
  protected $keyAuth;

  /**
   * Constructs a key authentication page cache policy.
   *
   * @param \Drupal\key_auth\KeyAuthInterface $key_auth
   *   The key auth service..
   */
  public function __construct(KeyAuthInterface $key_auth) {
    $this->keyAuth = $key_auth;
  }

  /**
   * {@inheritdoc}
   */
  public function check(Request $request) {
    if ($this->keyAuth
      ->getKey($request)) {
      return self::DENY;
    }
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DisallowKeyAuthRequests::$keyAuth protected property The key auth service.
DisallowKeyAuthRequests::check public function Determines whether delivery of a cached page should be attempted. Overrides RequestPolicyInterface::check
DisallowKeyAuthRequests::__construct public function Constructs a key authentication page cache policy.
RequestPolicyInterface::ALLOW constant Allow delivery of cached pages.
RequestPolicyInterface::DENY constant Deny delivery of cached pages.