BasicAuth::challengeException

public BasicAuth::challengeException(Request $request, \Exception $previous)

Constructs an exception which is used to generate the challenge.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

\Exception $previous: The previous exception.

Return value

\Symfony\Component\HttpKernel\Exception\HttpExceptionInterface|null An exception to be used in order to generate an authentication challenge.

Overrides AuthenticationProviderChallengeInterface::challengeException

File

core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php, line 128

Class

BasicAuth
HTTP Basic authentication provider.

Namespace

Drupal\basic_auth\Authentication\Provider

Code

public function challengeException(Request $request, \Exception $previous) {
  $site_name = $this->configFactory->get('system.site')->get('name');
  $challenge = SafeMarkup::format('Basic realm="@realm"', array(
    '@realm' => !empty($site_name) ? $site_name : 'Access restricted',
  ));
  return new UnauthorizedHttpException((string) $challenge, 'No authentication credentials provided.', $previous);
}
doc_Drupal
2016-10-29 08:45:58
Comments
Leave a Comment

Please login to continue.