我只是尝试使用JWT登录创建我的sf3 api,但我在验证方面遇到了一些麻烦.所以这是我的配置和一些我意识到的测试.
security.yml:
security:
firewalls:
login:
pattern: ^/api/auth
stateless: true
anonymous: true
form_login:
check_path: /api/auth/login-check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
api:
pattern: ^/api
stateless: true
lexik_jwt: ~
access_control:
- { path: ^/api/auth, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
Run Code Online (Sandbox Code Playgroud)
routing.yml中:
auth:
path: /auth
defaults: { _controller: api.controller.auth:postAction }
methods: [OPTIONS, POST]
api_login_check:
path: /auth/login-check
Run Code Online (Sandbox Code Playgroud)
config.yml:
nelmio_cors:
paths:
'^/api/':
allow_origin: ['*']
allow_headers: ['*']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'OPTIONS']
max_age: 3600
Run Code Online (Sandbox Code Playgroud)
当我调试路由时,我收到此输出:
$ php bin/console debug:router
----------------------------------- …Run Code Online (Sandbox Code Playgroud)