2014-03-19 24 views
0

login_form結果我收到以下異常,如果我使用了 「simple_form」 - 選項在我security.yml:Symfony的V2.4 simple_form>在ServiceNotFoundException的

ServiceNotFoundException: The service "security.firewall.map.context.secured_area" 
has a dependency on a non-existent service 
"security.authentication.success_handler.secured_area.simple_form". 

我需要 「simple_form」 sinds它「認證者」 - 選項。 使用 「form_login」 導致以下異常:

InvalidConfigurationException: Unrecognized options "authenticator" under "security.firewalls.secured_area.form_login" 

我security.yml(僅適用於相關的配置拷貝)

security: 
    firewalls: 
    secured_area: 
     simple_form: 
     login_path: /login 
     check_path: /login_check 
     authenticator: some_wild_authenticator 
     use_referer: true 
     csrf_provider: form.csrf_provider 
     success_handler: security.authentication.success_handler 
     failure_handler: security.authentication.failure_handler 

我錯過了什麼?錯誤?不可能?解?解決方法?

我跑這個SF2.4

Source

+0

'模式導致:^/your_pattern'缺少 – Nisam

+0

不,我沒有,沒有複製它,因爲它是不相關的。 – Airoude

+0

請看看我的安全配置,http://pastebin.com/ZJgC0LZw其爲我工作 – Nisam

回答

-1

使用FOS用戶捆綁 FOS User Bundle。請參閱文檔並正確配置此安全防火牆。

+0

此捆綁將是我推薦的最後一個。 –

+0

@Anyone爲什麼呢? –

+2

(1)由於FOS Bundles包含90%不需要的代碼,因此應該分開。 (2)只要您按照設計的方式使用它,而不需要進行自定義更改,那麼捆綁只是一種很好的方式。 –

0

嘗試添加以下到您的services.yml:

parameters: 
    custom.success.handler.class: Acme\DemoBundle\Security\CustomLoginSuccessHandler 

services: 
    security.authentication.success_handler.secured_area.simple_form: 
     class: %custom.success.handler.class% 
     tags: 
      - { name: 'monolog.logger', channel: 'security' } 

與項目有關的信息替換「自定義成功處理程序」的東西。

0

我發現(這不是一個「最佳實踐」)的解決方法。

我重新定義了我的success_handler服務爲「security.authentication.success_handler.secured_area.simple_form」(或者在我的情況下 - 與「secured_area」不同的字符串)。

通過給它的名稱,而不是使用simple_form下的「success_handler」選項,我能夠使用我的成功處理程序。

我希望他們很快就能解決這個問題,因爲這種解決方法讓我在更新過程中有點不安。

1

有在Symfony的一個錯誤,你必須註冊success_handler作爲服務ID security.authentication.success_handler.secured_area.simple_form,使用其他名稱爲服務將與例外

ServiceNotFoundException: The service "security.firewall.map.context.secured_area" has a dependency on a non-existent service "security.authentication.success_handler.secured_area.simple_form".

error仍然出現在Symfony的2.5.8