[英]Azure authentication Symfony
我已经创建了一个 Symfony 4.2 应用程序,我想在其中添加 Microsoft 身份验证,所以在网上进行了大量研究后,我发现了一个名为HWIOAuthBundle的库,我已经按照每一步操作,但我仍然有问题
如果有人可以帮助我,那将非常有帮助
hwi_oauth.yaml 文件:
#/config/packages/hwi_oauth.yaml
hwi_oauth:
# list of names of the firewalls in which this bundle is active, this setting MUST be set
firewall_names: [secured_area]
# https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/2-configuring_resource_owners.md
resource_owners:
azure:
type: azure
client_id: '%env(AZURE_ID)%'
client_secret: '%env(AZURE_SECRET)%'
options:
resource: https://graph.windows.net
application: common
这是我的安全文件:
#/config/packages/security.yaml
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
secured_area:
anonymous: true
oauth:
resource_owners:
azure: "/login/check-azure"
login_path: /login
use_forward: false
failure_path: /login
oauth_user_provider:
service: my.oauth_aware.user_provider.service
# activate different ways to authenticate
# http_basic: true
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
# form_login: true
# https://symfony.com/doc/current/security/form_login_setup.html
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
我运行php bin/console server:run
时出现错误: The service "hwi_oauth.authentication.provider.oauth.secured_area" has a dependency on a non-existent ser vice "my.oauth_aware.user_provider.service".
提前致谢
斯托菲勒
您正在security.yml
文件中定义一个名为my.oauth_aware.user_provider.service
的用户提供者
oauth_user_provider:
service: my.oauth_aware.user_provider.service
您需要使用该名称定义服务或使用默认服务之一
hwi_oauth.user.provider
hwi_oauth.user.provider.entity
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.