Skip to content

Finished #3759 #4128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update api_key_authentication.rst - POST Method
  • Loading branch information
BourotBenjamin authored and wouterj committed Aug 16, 2014
commit 59e4bd4c2a6d23d02f518cc83a21fe2cbbfad6dc
26 changes: 18 additions & 8 deletions cookbook/security/api_key_authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,25 @@ value and then a User object is created::

public function createToken(Request $request, $providerKey)
{
if (!$request->query->has('apikey')) {
throw new BadCredentialsException('No API key found');
if ($request->query->has('apikey')) {
return new PreAuthenticatedToken(
'anon.',
$request->query->get('apikey'),
$providerKey
);
}

return new PreAuthenticatedToken(
'anon.',
$request->query->get('apikey'),
$providerKey
);
else if($request->request->has('apikey'))
{
return new PreAuthenticatedToken(
'anon.',
$request->request->get('apikey'),
$providerKey
);
}
else
{
throw new BadCredentialsException('No API key found');
}
}

public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
Expand Down