Symfony:使用API​​ KEY进行身份验证不会保留会话

时间:2014-03-01 01:39:15

标签: api symfony authentication

作为Symfony手册,我按照以下步骤http://symfony.com/doc/current/cookbook/security/api_key_authentication.html通过URL中提供的外部令牌启用身份验证。

当我在URL Symfony中传递令牌时,请执行登录,但如果我更改页面,则会丢失会话。

这是代码:

public function createToken(Request $request, $providerKey)
{

    $targetUrl = '/myproject/login';
    if (!$this->httpUtils->checkRequestPath($request, $targetUrl)) {
        // DO REDIRECT
    }

    if (!$request->query->has('apikey')) {
        throw new BadCredentialsException('No API key found');
    }

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

由于

0 个答案:

没有答案