我正在为Symfony 5使用KnpUOAuth2ClientBundle。当我进入页面时,如果用户没有登录,那么它会重定向到 gitlab 页面,并在身份验证时成功重定向到我存储 cookie 的主页。
但是在我注销 gitlab 并检查我的主页后,它仍然可以作为存储 cookie 的工作。
这似乎是错误的。我应该怎么做,如果 gitlab 退出,cookie 被清除。
这是我的security.yaml
文件
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
app_user_provider:
id: App\Security\UserProvider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
guard:
authenticators:
- App\Security\GitlabAuthenticator
access_control:
- { path: ^/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: ROLE_USER }
我不确定我正在尝试做的事情是否正确。在 GitlabAuthController 我有 connectAction 方法,我试图清除 cookie 集
public function connectAction(ClientRegistry $clientRegistry): RedirectResponse
{
if ($this->logout()->getStatusCode() === 200) {
// will redirect to gitlab!
return $clientRegistry
->getClient('gitlab') // key used in config/packages/knpu_oauth2_client.yaml
->redirect()
;
}
}
public function logout()
{
$response = new Response();
$response->headers->clearCookie('PHPSESSID');
return $response->send();
}
但是有了这个我得到了Invalid state parameter passed in callback URL.
错误。