0

I am trying to integrate HWIOAuthBundle in my Symfony 4.1 application.

I followed the documentation regarding the installation of the bundle. Here are snippets of my configuration files:

# 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:
        google:
            type:                google
            client_id:           '%env(GOOGLE_AUTH_ID)%'
            client_secret:       '%env(GOOGLE_AUTH_SECRET)%'
            scope:               "email"
            options:
                display: popup
                csrf: true


# config/services.yaml

services:
    hwi_oauth.resource_ownermap.secured_area:
        class: HWI\Bundle\OAuthBundle\Security\Http\ResourceOwnerMap


# config/security.yml

security:
    firewalls:
        secured_area:
            anonymous: ~
            oauth:
                resource_owners:
                    google: "/login/check-google"
                login_path: "/login"
                use_forward: false
                failure_path: "/login"
                oauth_user_provider:
                    service: hwi_oauth.user.provider

However when I run

composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

I get the following error:

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!      
!!  In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:
!!                                                                                 
!!    The service "hwi_oauth.security.oauth_utils" has a dependency on a non-exis  
!!    tent service "hwi_oauth.resource_ownermap.secured_area".                     
!!                                                                                 
!!  
!!  
Script @auto-scripts was called via post-update-cmd

What am I doing wrong?

Victor
  • 13,914
  • 19
  • 78
  • 147
  • Can you check your `AppKernel` to make sure `HWIOAuthBundle` has been activated? – Jovan Perovic Aug 02 '18 at 10:26
  • @JovanPerovic I have `HWI\Bundle\OAuthBundle\HWIOAuthBundle::class => ['all' => true` in my `config/bundles.php` file. Is that what you're asking? – Victor Aug 02 '18 at 10:33
  • Yes, thank you. Weird, it is like autoloader does not know how to reach bundle's classes. As dummy as it sounds, I assume that your checked that the bundle was in fact fully installed? :) Did you optimize your project to have `composer` dump found prefixes? – Jovan Perovic Aug 02 '18 at 10:39
  • @JovanPerovic I didn't check if the bundle was fully installed as Composer install finished successfully. I assumed there was no problem regarding the installation. But the script fails after the installation – Victor Aug 02 '18 at 10:47
  • As you guessed, it should not be an issue. What about composer dumping of autoload? In addition, have you enabled `OPCache`? Try running `composer dump-autoload` and restarting your web server in order to make sure it reindexes your classpaths... – Jovan Perovic Aug 02 '18 at 10:53
  • I tried both. Nothing works – Victor Aug 02 '18 at 11:31
  • Why is the error message in your question different than the one in your title? I can offer suggestions on why autowire is not working but you seem to have two unrelated issues. If you comment out the HWI lines in services.yaml does "bin/console debug:container" work? Have you verified that the oauth bundle has been upgraded to support Symfony 4? – Cerad Aug 02 '18 at 12:10

0 Answers0