1

I've created a Symfony 4.2 app, and i want to add a Microsoft authentication in it, so after many research on the web I've found a library called HWIOAuthBundle i've followed everystep but I still have issue

If anyome can help me it can be very helpfull

hwi_oauth.yaml file :

#/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

Here it's my security file :

#/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 }

My error when I run 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".

Thanks in advance

Stoufiler

Stoufiler
  • 175
  • 1
  • 2
  • 13

1 Answers1

1

You are defining an user provider called my.oauth_aware.user_provider.service in the security.ymlfile

oauth_user_provider:
    service: my.oauth_aware.user_provider.service

You need to define a service with that name or use one of the default ones

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

alexgt9
  • 11
  • 1