class ShibbolethAuthenticationProvider in Shibboleth Authentication 8.4
Class ShibbolethAuthenticationProvider.
@package Drupal\shib_auth\Authentication\Provider
Hierarchy
- class \Drupal\shib_auth\Authentication\Provider\ShibbolethAuthenticationProvider implements AuthenticationProviderInterface
Expanded class hierarchy of ShibbolethAuthenticationProvider
1 string reference to 'ShibbolethAuthenticationProvider'
1 service uses ShibbolethAuthenticationProvider
File
- src/
Authentication/ Provider/ ShibbolethAuthenticationProvider.php, line 23 - Contains Drupal\shib_auth\Authentication\Provider\ShibbolethAuthenticationProvider.
Namespace
Drupal\shib_auth\Authentication\ProviderView source
class ShibbolethAuthenticationProvider implements AuthenticationProviderInterface {
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* Constructs a HTTP basic authentication provider object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager service.
*/
public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager) {
$this->configFactory = $config_factory;
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public function applies(Request $request) {
// If Authentication Provider is enabled always apply.
return TRUE;
}
/**
* {@inheritdoc}
*/
public function authenticate(Request $request) {
$consumer_ip = $request
->getClientIp(TRUE);
if (in_array($consumer_ip, $ips)) {
// Return Anonymous user.
return $this->entityManager
->getStorage('user')
->load(0);
}
else {
throw new AccessDeniedHttpException();
}
}
/**
* {@inheritdoc}
*/
public function cleanup(Request $request) {
}
/**
* {@inheritdoc}
*/
public function handleException(GetResponseForExceptionEvent $event) {
$exception = $event
->getException();
if ($exception instanceof AccessDeniedHttpException) {
$event
->setException(new UnauthorizedHttpException('Invalid consumer origin.', $exception));
return TRUE;
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ShibbolethAuthenticationProvider:: |
protected | property | The config factory. | |
ShibbolethAuthenticationProvider:: |
protected | property | The entity manager. | |
ShibbolethAuthenticationProvider:: |
public | function |
Checks whether suitable authentication credentials are on the request. Overrides AuthenticationProviderInterface:: |
|
ShibbolethAuthenticationProvider:: |
public | function |
Authenticates the user. Overrides AuthenticationProviderInterface:: |
|
ShibbolethAuthenticationProvider:: |
public | function | ||
ShibbolethAuthenticationProvider:: |
public | function | ||
ShibbolethAuthenticationProvider:: |
public | function | Constructs a HTTP basic authentication provider object. |