In HWIOAuthBundle,
There is samples to use FOSUserbundle
in the document.
my.oauth_aware.user_provider.service:
class: HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider
arguments:
- '@fos_user.user_manager'
- ['pass properties as array']
However in my case (Symfony4.4), there is already native security system and set up in security.yaml.
security:
app_user_provider:
entity:
class: App\Entity\User
property: email
So I want to make HWIAOuthBundle
to use this native security system.
my.oauth_aware.user_provider.service:
class: HWI\Bundle\OAuthBundle\Security\Core\User\EntityUserProvider
arguments:
class: App\Entity\User
property: email
However it shows like this,
Invalid service "my.oauth_aware.user_provider.service": did you forget to add the "$" prefix to argument "class"?
How can I use HWIOAuthBundle
without FOSUserBundle
??
services.yaml
parameters:
services:
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
my.oauth_aware.user_provider.service:
class: HWI\Bundle\OAuthBundle\Security\Core\User\EntityUserProvider
arguments:
class: App\Entity\User
property: email
hwi_oauth:
resource_owners:
any_name:
type: facebook
client_id: <client_id>
client_secret: <client_secret>
security.yaml
security:
encoders:
App\Entity\User:
algorithm: auto
providers:
app_user_provider:
entity:
class: App\Entity\User
property: email
access_control:
# require ROLE_ADMIN for /admin*
# - { path: '^/admin', roles: ROLE_ADMIN }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
guard:
authenticators:
- App\Security\LoginFormAuthenticator
logout:
path: app_logout
oauth:
resource_owners:
vkontakte: "/social-login/check-vkontakte"
facebook: "/social-login/check-facebook"
google: "/social-login/check-google"
twitter: "/social-login/check-twitter"
login_path: /login
use_forward: false
failure_path: /login
oauth_user_provider:
service: my.oauth_aware.user_provider.service