dsxcv5652 2016-11-15 15:12
浏览 64

Symfony控制台命令:令牌存储不包含身份验证令牌

When I try to launch my custom made Symfony command using php bin/console I get this bizarre error :

[Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException]

The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL

Its seem that the line responsible is

$user = $em->getRepository('CoreUserBundle:User')->findOneById($deck['user_id']);
            if ($user != null)
            {
                $deck_entity = new Deck();
                $deck_entity->SetId($deck['id']);
                $deck_entity->SetUser($user);
                $deck_entity->SetTitle($deck['titre']);
                $deck_entity->SetClass($deck['classe']);
                $deck_entity->SetStyle("None");
                $deck_entity->SetContentHtml($deck['contenu_html']);
                if (isset($deck['contenu_bbcode']))
                    $deck_entity->SetContentBBCode($deck['contenu_bbcode']);
                $deck_entity->SetVideo($deck['video']);
                $deck_entity->SetVersion($deck['version']);
                $deck_entity->SetIsUpdated($deck['a_jour']);
                $deck_entity->SetCraftCost($deck['craft_cout']);
                $deck_entity->SetCreationDate(new \DateTime($deck['creation']));
                $deck_entity->SetEditionDate(new \DateTime($deck['edition']));
                $deck_entity->SetDeckType($deck['deck_type']);


                $em->persist($deck_entity);

                $metadata = $em->getClassMetaData(get_class($deck_entity));
                $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
            }

UPDATE : Its seem that the error happen at the moment of persisting the entity Deck().

My firewall security are

    firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    main:
        pattern:  ^/
        form_login:
            login_path: /login
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
            remember_me:   true
        oauth:
            resource_owners:
                facebook: /login/check-facebook
                google: /login/check-google
            login_path: /login
            failure_path: /login
            oauth_user_provider:
                service: core.user.user_provider
        remember_me:
            secret:    "%secret%"
            name:      f1e56d001
            lifetime:  604800
            httponly:  true
            domain:    xxxx.eu
        logout:
            path:    fos_user_security_logout
            handlers: ['sonata.page.cms_manager_selector']
            target:  /
        anonymous:  true
        switch_user:
            role:       ROLE_ADMINISTRATOR
            parameter:  connect_as

I don't understand what I am supposed to, the error seem to tell me that i'm not authenticated, but how since I am using the console ?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douyan1613 2016-11-16 16:14
    关注

    after more research, its appear my Deck() entity was triggering a PostPersist event made to create a new thread from the FosCommentBundle, which apparently needed to have the currently logged user to process some stuff (which couldn't get because of the command being a console command ), I could fix the problem by bypassing these event.

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)