You are here

public function ShibbolethAuthenticationProvider::authenticate in Shibboleth Authentication 8.4

Authenticates the user.

Parameters

\Symfony\Component\HttpFoundation\Request|null $request: The request object.

Return value

\Drupal\Core\Session\AccountInterface|null AccountInterface - in case of a successful authentication. NULL - in case where authentication failed.

Overrides AuthenticationProviderInterface::authenticate

File

src/Authentication/Provider/ShibbolethAuthenticationProvider.php, line 58
Contains Drupal\shib_auth\Authentication\Provider\ShibbolethAuthenticationProvider.

Class

ShibbolethAuthenticationProvider
Class ShibbolethAuthenticationProvider.

Namespace

Drupal\shib_auth\Authentication\Provider

Code

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();
  }
}