class ForceLoginController in CAS 8
Same name and namespace in other branches
- 2.x src/Controller/ForceLoginController.php \Drupal\cas\Controller\ForceLoginController
Class ForceLoginController.
Used to force CAS authentication for anonymous users.
Hierarchy
- class \Drupal\cas\Controller\ForceLoginController implements ContainerInjectionInterface
Expanded class hierarchy of ForceLoginController
File
- src/
Controller/ ForceLoginController.php, line 16
Namespace
Drupal\cas\ControllerView source
class ForceLoginController implements ContainerInjectionInterface {
/**
* The cas helper to get config settings from.
*
* @var \Drupal\cas\Service\CasRedirector
*/
protected $casRedirector;
/**
* Used to get query string parameters from the request.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* Constructor.
*
* @param \Drupal\cas\Service\CasRedirector $cas_redirector
* The CAS Redirector service.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* Symfony request stack.
*/
public function __construct(CasRedirector $cas_redirector, RequestStack $request_stack) {
$this->casRedirector = $cas_redirector;
$this->requestStack = $request_stack;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('cas.redirector'), $container
->get('request_stack'));
}
/**
* Handles a page request for our forced login route.
*/
public function forceLogin() {
// TODO: What if CAS is not configured? need to handle that case.
$service_url_query_params = $this->requestStack
->getCurrentRequest()->query
->all();
$cas_redirect_data = new CasRedirectData($service_url_query_params);
$cas_redirect_data
->setIsCacheable(TRUE);
return $this->casRedirector
->buildRedirectResponse($cas_redirect_data, TRUE);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ForceLoginController:: |
protected | property | The cas helper to get config settings from. | |
ForceLoginController:: |
protected | property | Used to get query string parameters from the request. | |
ForceLoginController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
ForceLoginController:: |
public | function | Handles a page request for our forced login route. | |
ForceLoginController:: |
public | function | Constructor. |