Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Symfony2][SF][SF2]Problem przy instalacji FosUserBundle
Forum PHP.pl > Forum > PHP > Frameworki
Crash89
Próbuję zainstalować najnowsze FosUserBundle do Symfony 2.6.6
Robię wszystko tak jak jest opisane w instrukcji do instalacji pakietu,ale w momencie aktualizacji struktury bazy danych
Wyskakuje błąd:

unrecognized option "csrf_provider" under "security.firewalls.user"



Poniżej przedstawiam zawartość security.yml:
  1. # you can read more about security in the related section of the documentation
  2. security:
  3. encoders:
  4. Symfony\Component\Security\Core\User\User: plaintext
  5. FOS\UserBundle\Model\UserInterface: sha512
  6.  
  7. role_hierarchy:
  8. ROLE_ADMIN: ROLE_USER
  9. ROLE_SUPER_ADMIN: ROLE_ADMIN
  10. providers:
  11. fos_userbundle:
  12. id: fos_user.user_provider.username
  13. # the main part of the security, where you can set up firewalls
  14. # for specific sections of your app
  15. firewalls:
  16. user:
  17. pattern: ^/
  18. form_login:
  19. provider:
  20. fos_userbundle
  21. csrf_provider:
  22. security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4
  23. logout: true
  24. #path: logout
  25. #target: _demo
  26. anonymous: true
  27. dev:
  28. pattern: ^/(_(profiler|wdt)|css|images|js)/
  29. security: false
  30.  
  31. login:
  32. pattern: ^/demo/secured/login$
  33. security: false
  34.  
  35. secured_area:
  36. pattern: ^/demo/secured/
  37. form_login:
  38. check_path: _security_check
  39. login_path: _demo_login
  40. logout:
  41. path: _demo_logout
  42. target: _demo
  43. # disables authentication for assets and the profiler, adapt it according to your needs
  44.  
  45. # the login page has to be accessible for everybody
  46.  
  47.  
  48. # secures part of the application
  49.  
  50. #http_basic:
  51. # realm: "Secured Demo Area"
  52.  
  53. # with these settings you can restrict or allow access for different parts
  54. # of your application based on roles, ip, host or methods
  55. access_control:
  56. - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
  57. - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
  58. - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
  59. - { path: ^/admin/, role: ROLE_ADMIN }

i config.yml:
  1. framework:
  2. #esi: ~
  3. translator: ~
  4. secret: "%secret%"
  5. router:
  6. resource: "%kernel.root_dir%/config/routing.yml"
  7. strict_requirements: ~
  8. form: ~
  9. csrf_protection: ~
  10. validation: { enable_annotations: true }
  11. templating:
  12. engines: ['twig']
  13. #assets_version: SomeVersionScheme
  14. default_locale: "%locale%"
  15. trusted_hosts: ~
  16. trusted_proxies: ~
  17. session:
  18. # handler_id set to null will use default session handler from php.ini
  19. handler_id: ~
  20. fragments: ~
  21. http_method_override: true


Próbowałem zmienić wartosc framework.csrf_protection na enable: true ale to nic nie dało.
Wydaje mi się że problem leży przy wpisaniu poprawnej wartośći do csrf_provider, niestety nie wiem jaka to jest.
Damonsson
Wcięcia kolego. provider, csrf_provider itd. należą do form_login, więc muszą mieć jedno wcięcie więcej. Zresztą komunikat masz jasny, że nie należą do security.firewalls.user i nie mają prawa tam być. Zobacz sobie dokumentację FOSUserBundle jak powinien wyglądać security.yml
Crash89
Wcześniej wszystko skopiowałem ze strony dokumentacji FosUserBundle i miałem problemy z bitami przesunięcia, itp.
Przez to trochę te wartości poprzesuwałem, a nie wiedziałem że w Yamlu wcięcia mają aż takie znaczenie.
Jestem początkujący w Symfony, ale format Yaml jest dla mnie specyficzny.
Teraz działa, Dzięki za pomoc.
Damonsson
Poczuj się jakbyś pisał w Python biggrin.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.