首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Symfony 6社交登录记得我不工作

Symfony 6社交登录记得我不工作
EN

Stack Overflow用户
提问于 2022-07-26 11:55:29
回答 1查看 270关注 0票数 0

我已经更新了我的项目到Symfony 6,现在我的谷歌登录不再像以前那样工作。如果关闭浏览器,记住我的令牌就不能工作。在5.4中,我的security.yaml是这样写的:

代码语言:javascript
复制
google:
  pattern: ^/connect/google
  guard:
    authenticators:
      - App\Security\GoogleAuthenticator
  logout:
    path: app_logout
    target: home
  remember_me:
    secret: "%env(GOOGLE_CLIENT_SECRET)%"
    lifetime: 604800
    always_remember_me: true

但现在克莱告诉我我需要换个“警卫”。如果我使用custom_authenticator选项,会出现很多错误,因为我使用的是SocialAuthenticator,正如您在这里看到的那样:https://codeshare.io/Od84jx --如果我从security.yaml中删除google部件--我没有错误,注册和登录工作,但不记得me令牌。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-27 13:10:39

我终于成功了,我为那些有同样问题的人分享我的解决方案。

因此,在symfony 5.4到symfony 6.1中,您需要使用OAuth2Authenticator而不是SocialAuthenticator。您可以按照文档编写GoogleAuthenticator:https://github.com/knpuniversity/oauth2-client-bundle#step-1-using-the-new-oauth2authenticator-class

然后,只需将其添加到custom_authenticator文件中的security.yaml部分。例如:

代码语言:javascript
复制
 main:
      switch_user: true
      lazy: true
      provider: app_user_provider
      custom_authenticator: 
        - App\Security\LoginAuthenticator
        - App\Security\GoogleAuthenticator

如果你已经有了控制器,它就能工作了。(https://github.com/knpuniversity/oauth2-client-bundle#step-3-use-the-client-service)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73122951

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档