You are here

public function BasicAuthentication::applies in RESTful 7.2

Determines if the request can be checked for authentication. For example, when authenticating with HTTP header, return FALSE if the header values do not exist.

Parameters

RequestInterface $request: The request.

Return value

bool TRUE if the request can be checked for authentication, FALSE otherwise.

Overrides Authentication::applies

File

src/Plugin/authentication/BasicAuthentication.php, line 29
Contains \Drupal\restful\Plugin\authentication\BasicAuthentication

Class

BasicAuthentication
Class BasicAuthentication @package Drupal\restful\Plugin\authentication

Namespace

Drupal\restful\Plugin\authentication

Code

public function applies(RequestInterface $request) {
  if (variable_get('restful_skip_basic_auth', FALSE)) {

    // Skip basic auth. The variable may be set if .htaccess password is set
    // on the server.
    return NULL;
  }
  $username = $request
    ->getUser();
  $password = $request
    ->getPassword();
  return isset($username) && isset($password);
}