You are here

public function ApiKeyAuth::getKey in Services API Key Authentication 8

Same name and namespace in other branches
  1. 8.2 src/Authentication/Provider/ApiKeyAuth.php \Drupal\services_api_key_auth\Authentication\Provider\ApiKeyAuth::getKey()
  2. 3.0.x src/Authentication/Provider/ApiKeyAuth.php \Drupal\services_api_key_auth\Authentication\Provider\ApiKeyAuth::getKey()
  3. 2.0.x src/Authentication/Provider/ApiKeyAuth.php \Drupal\services_api_key_auth\Authentication\Provider\ApiKeyAuth::getKey()

Parameters

$request:

Return value

bool

2 calls to ApiKeyAuth::getKey()
ApiKeyAuth::applies in src/Authentication/Provider/ApiKeyAuth.php
Checks whether suitable authentication credentials are on the request.
ApiKeyAuth::authenticate in src/Authentication/Provider/ApiKeyAuth.php
Authenticates the user.

File

src/Authentication/Provider/ApiKeyAuth.php, line 106

Class

ApiKeyAuth
HTTP Basic authentication provider.

Namespace

Drupal\services_api_key_auth\Authentication\Provider

Code

public function getKey(Request $request) {
  $form_api_key = $request
    ->get('api_key');
  if (!empty($form_api_key)) {
    return $form_api_key;
  }
  $query_api_key = $request->query
    ->get('api_key');
  if (!empty($form_api_key)) {
    return $query_api_key;
  }
  $header_api_key = $request->headers
    ->get('apikey');
  if (!empty($header_api_key)) {
    return $header_api_key;
  }
  return FALSE;
}