我想在执行身份验证之前执行用户名(字符数和有效电子邮件)和密码(字符数)的传统验证。
用户在数据库中,我不想在验证成功之前访问数据库。
我用 Symfony 4.1 设置了 LexikJWTAuthenticationBundle 并且它正在工作。没有控制器,因为身份验证完全由捆绑包处理。
我不确定如何执行上述验证。请帮忙。
在我的安全配置下方查找以了解我已经设置的内容。
security:
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ]
encoders:
App\Entity\User:
id: app.bcrypt_plus_encoder
providers:
db_user_provider:
entity:
class: App\Entity\User
# the property to query by - e.g. username, email, etc
property: email
# if you're using multiple entity managers
# manager_name: customer
firewalls:
guest:
pattern: ^/api/guest
stateless: true
anonymous: true
login:
pattern: ^/api/login
user_checker: App\Security\UserChecker
stateless: true
anonymous: true
provider: db_user_provider
json_login:
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: App\Security\Http\Authentication\AuthenticationFailureHandler
require_previous_session: false
username_path: email
password_path: passw
api:
pattern: ^/api
stateless: true
guard:
provider: db_user_provider
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
access_control:
- { path: ^/api/guest, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }