0

FOSUserBundle을 사용하여 JWT 인증을 시도하는 API 플랫폼을 처음 사용했습니다. csrf_protection -로드 할 수있는 확장자 없음

나는 차근 다음 단계 https://symfony.com/doc/master/bundles/FOSUserBundle/index.html 튜토리얼 내가 시도 5 단계 이후에 내가 잘못을 얻을 1 단계를 다시 실행 :

"csrf_protection"에 대한 구성을로드 할 수 확장자가 없습니다

(E의를 : \ rest-api \ app/config \ config.yml). 네임 스페이스 "csrf_protection"을 찾았습니다. f ound "framework"...

또한 업데이트 계획을 시도 할 때 동일한 오류가 발생합니다. 어떤 도움 ??

이이 내가

api_platform: 
    http_cache: 
     invalidation: 
      enabled: true 
      #varnish_urls: '%varnish_urls%' 
     max_age: 0 
     shared_max_age: 3600 
     vary: ['Content-Type', 'Authorization'] 
     public: true 
    swagger: 
     api_keys: 
      - { name: 'Authorization', type: 'header'} 
    enable_fos_user: true 

fos_user: 
    db_driver: orm # other valid values are 'mongodb' and 'couchdb' 
    firewall_name: main 
    user_class: AppBundle\Entity\AuthUser 
    from_email: 
     address: "%mailer_user%" 
     sender_name: "%mailer_user%" 

csrf_protection: 
    enabled: false 

AppKernel.php

public function registerBundles() 
{ 
    $bundles = [ 
     new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 
     new Symfony\Bundle\SecurityBundle\SecurityBundle(), 
     new Symfony\Bundle\TwigBundle\TwigBundle(), 
     new Symfony\Bundle\MonologBundle\MonologBundle(), 
     new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), 
     new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), 
     new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), 
     new ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle(), 
     new Nelmio\CorsBundle\NelmioCorsBundle(), 
     new AppBundle\AppBundle(), 
     new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(), 
     new FOS\UserBundle\FOSUserBundle(), 
     new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), 
    ]; 

모든 suggestuion/도움 config.yml에 추가 것입니다 내 security.yml

security: 

    encoders: 
      FOS\UserBundle\Model\UserInterface: bcrypt 

    role_hierarchy: 
      ROLE_ADMIN:  ROLE_USER 
      ROLE_SUPER_ADMIN: ROLE_ADMIN 


    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers 
    providers: 
     in_memory: 
      memory: ~ 

     fos_userbundle: 
        id: fos_user.user_provider.username 


    firewalls: 

     # disables authentication for assets and the profiler, adapt it according to your needs 
     dev: 

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


     main: 
      pattern: ^/ 
      form_login: 
          provider: fos_userbundle 
          Scsrf_token_generator: security.csrf.token_manager 
          #csrf_provider: form.csrf_provider 
      logout:  true 
      anonymous: true 


    access_control: 
       - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } 
       - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } 
       - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } 
       - { path: ^/admin/, role: ROLE_ADMIN } 

입니까?

+1

csrf_protection 섹션은 프레임 워크 섹션 아래에 있어야합니다. Symfony의 버전에 따라 이미 존재할 수도 있습니다. 그런데 csrf_protection을 전역 적으로 비활성화하는 것은 일반적으로 나쁜 생각으로 간주됩니다. 그리고 당신이 게시 한 링크에는 아무것도하지 말라고 말하지 않습니다. – Cerad

+0

감사합니다. @Cerad 맞습니다. csrf_protection은 프레임 워크 섹션에 있습니다. –

답변

0

은이 문서를 참조하십시오 : https://api-platform.com/docs/core/fosuser-bundle/를 그들이 API를 플랫폼으로 JWT위한 인증 통합을위한 좋은 자습서를 가지고 . 행운을 빕니다 !

+0

구성이 잘못되었습니다. 나는이 문서를 사용하고 있지만 괜찮습니다. 이제 토큰을 설정하기 위해 Api-platform 홈페이지에 액세스 할 수 없습니다. 나는이 튜토리얼을 따라갈 것이다. 감사 !! –

0

것은 당신의 config.yml에서이 csrf_protection의 설정을 제거 당신이 당신의 설정에 잘못된 구성을 생각

csrf_protection: 
    enabled: false 
+0

감사합니다. 내 구성이 좋지 않았지만 csrf_protection이 이미 프레임 워크 섹션에 있기 때문에 이것이 첫 번째 문제였습니다. –

관련 문제