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