Skip to content

Commit

Permalink
feature #4128 Finished #3759 (WouterJ)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.4 branch.

Discussion
----------

Finished #3759

Finished the great start by @BourotBenjamin in #3759

Commits
-------

529675a Check for api_key in request
59e4bd4 Update api_key_authentication.rst - POST Method
  • Loading branch information
weaverryan committed Aug 16, 2014
2 parents 4629d8b + 529675a commit 08bed5f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cookbook/security/api_key_authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ value and then a User object is created::

public function createToken(Request $request, $providerKey)
{
if (!$request->query->has('apikey')) {
// look for an apikey query parameter
$apiKey = $request->query->get('apikey');

// or if you want to use an "apikey" header, then do something like this:
// $apiKey = $request->headers->get('apikey');

if (!$apiKey) {
throw new BadCredentialsException('No API key found');
}

return new PreAuthenticatedToken(
'anon.',
$request->query->get('apikey'),
$apiKey,
$providerKey
);
}
Expand Down

0 comments on commit 08bed5f

Please sign in to comment.