private function CasSubscriber::handleGateway in CAS 8
Check if the current path is a gateway path.
Return value
bool TRUE if current path is a gateway path, FALSE otherwise.
1 call to CasSubscriber::handleGateway()
- CasSubscriber::handle in src/
Subscriber/ CasSubscriber.php - The entry point for our subscriber.
File
- src/
Subscriber/ CasSubscriber.php, line 245
Class
- CasSubscriber
- Provides a CasSubscriber.
Namespace
Drupal\cas\SubscriberCode
private function handleGateway() {
// Don't do anything if this is a request from cron, drush, crawler, etc.
if ($this
->isCrawlerRequest()) {
return FALSE;
}
// Only implement gateway feature for GET requests, to prevent users from
// being redirected to CAS server for things like form submissions.
if (!$this->requestStack
->getCurrentRequest()
->isMethod('GET')) {
return FALSE;
}
if ($this->gatewayCheckFrequency === CasHelper::CHECK_NEVER) {
return FALSE;
}
// User can indicate specific paths to enable (or disable) gateway mode.
$condition = $this->conditionManager
->createInstance('request_path');
$condition
->setConfiguration($this->gatewayPaths);
if (!$this->conditionManager
->execute($condition)) {
return FALSE;
}
// If set to only implement gateway once per session, we use a session
// variable to store the fact that we've already done the gateway check
// so we don't keep doing it.
if ($this->gatewayCheckFrequency === CasHelper::CHECK_ONCE) {
// If the session var is already set, we know to back out.
if ($this->requestStack
->getCurrentRequest()
->getSession()
->has('cas_gateway_checked')) {
$this->casHelper
->log(LogLevel::DEBUG, 'CAS gateway auth has already been performed for this session.');
return FALSE;
}
$this->requestStack
->getCurrentRequest()
->getSession()
->set('cas_gateway_checked', TRUE);
}
return TRUE;
}