private function CasSubscriber::isCrawlerRequest in CAS 8
Check is the current request is from a known list of web crawlers.
We don't want to perform any CAS redirects in this case, because crawlers need to be able to index the pages.
Return value
bool True if the request is coming from a crawler, false otherwise.
1 call to CasSubscriber::isCrawlerRequest()
- CasSubscriber::handleGateway in src/
Subscriber/ CasSubscriber.php - Check if the current path is a gateway path.
File
- src/
Subscriber/ CasSubscriber.php, line 291
Class
- CasSubscriber
- Provides a CasSubscriber.
Namespace
Drupal\cas\SubscriberCode
private function isCrawlerRequest() {
$current_request = $this->requestStack
->getCurrentRequest();
if ($current_request->server
->get('HTTP_USER_AGENT')) {
$crawlers = [
'Google',
'msnbot',
'Rambler',
'Yahoo',
'AbachoBOT',
'accoona',
'AcoiRobot',
'ASPSeek',
'CrocCrawler',
'Dumbot',
'FAST-WebCrawler',
'GeonaBot',
'Gigabot',
'Lycos',
'MSRBOT',
'Scooter',
'AltaVista',
'IDBot',
'eStyle',
'Scrubby',
'gsa-crawler',
];
// Return on the first find.
foreach ($crawlers as $c) {
if (stripos($current_request->server
->get('HTTP_USER_AGENT'), $c) !== FALSE) {
$this->casHelper
->log(LogLevel::DEBUG, 'CasSubscriber ignoring request from suspected crawler "%crawler"', [
'%crawler' => $c,
]);
return TRUE;
}
}
}
return FALSE;
}