在新的 Symfony 5.4 應用程式中設定登錄表單身份驗證后,指定登錄提供程式時出現此錯誤。
路徑“security.firewalls.main.provider”的型別無效。預期“標量”,但得到“陣列”。
這是我的security.yml:
security:
enable_authenticator_manager: true
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
algorithm: auto
cost: 4
time_cost: 3
memory_cost: 10
providers:
users_in_memory: { memory: null }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider:
app_user_provider:
entity:
class: App\Entity\User
property: email
custom_authenticator: App\Security\AppAuthAuthenticator
logout:
path: app_logout
form_login:
login_path: app_login
check_path: app_login
enable_csrf: true
login_throttling:
max_attempts: 3
switch_user: true
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/dashboard, roles: ROLE_USER }
我在 macOS 13 系統上使用 PHP 8.1。附帶說明一下,切換到 PHP 7.4 并沒有解決問題。
uj5u.com熱心網友回復:
我認為您需要重新定位您的app_user_provider定義:
security:
enable_authenticator_manager: true
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
algorithm: auto
cost: 4
time_cost: 3
memory_cost: 10
providers:
# users_in_memory: { memory: null }
app_user_provider:
entity:
class: App\Entity\User
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider:
app_user_provider
...
檔案中有更多資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/530054.html
標籤:php交响乐安全yaml
