【问题标题】:Azure authentication SymfonyAzure 身份验证 Symfony
【发布时间】:2019-04-17 09:54:02
【问题描述】:

我已经创建了一个 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".

提前致谢

斯托菲尔

【问题讨论】:

    标签: php azure symfony authentication hwioauthbundle


    【解决方案1】:

    您正在security.ymlfile 中定义一个名为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
    

    https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/3-configuring_the_security_layer.md#step-3-configuring-the-security-layer

    【讨论】:

      猜你喜欢
      • 2015-02-02
      • 2012-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-16
      • 2021-12-23
      • 2023-03-20
      相关资源
      最近更新 更多