You are here

class CasRedirectResponse in CAS 8

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

Provides a non-cacheable redirect response to an outside server.

When returning a redirect response to a non-local URL (external server), you must use a response class that inherits from SecuredRedirectResponse.

Core provides one, called TrustedRedirectResponse, but it is cacheable, meaning Drupal's cache modules will attempt to cache the response.

We need a redirect response that is NOT cacheable, since when we redirect the user for gateway mode, there are far too many complexities involved construct the proper cache contexts and tags.

This response simply allows us to redirect a user to another site without worrying about Drupal caching that redirect response.

Hierarchy

Expanded class hierarchy of CasRedirectResponse

2 files declare their use of CasRedirectResponse
CasRedirector.php in src/Service/CasRedirector.php
LogoutController.php in src/Controller/LogoutController.php

File

src/CasRedirectResponse.php, line 23

Namespace

Drupal\cas
View source
class CasRedirectResponse extends SecuredRedirectResponse {

  /**
   * {@inheritdoc}
   */
  protected function isSafe($url) {
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CasRedirectResponse::isSafe protected function Returns whether the URL is considered as safe to redirect to. Overrides SecuredRedirectResponse::isSafe
SecuredRedirectResponse::createFromRedirectResponse public static function Copies an existing redirect response into a safe one.
SecuredRedirectResponse::fromResponse protected function Copies over the values from the given response. 1
SecuredRedirectResponse::setTargetUrl public function Sets the redirect target of this response.