Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 3, HWIOAuthBundle and FosUserBundle provider. #1108

Closed
fabionvs opened this issue Oct 4, 2016 · 3 comments
Closed

Symfony 3, HWIOAuthBundle and FosUserBundle provider. #1108

fabionvs opened this issue Oct 4, 2016 · 3 comments

Comments

@fabionvs
Copy link

fabionvs commented Oct 4, 2016

Hello guys,
I always used Symfony, HWIOAuthBundle and FosUserBundle together. But, on version 0.5 I am having many problems to interact them.
I need just an application that logs in from API's, and just persist the user entity from FOSUserBundle. But, for now the service hwi_oauth.user.provider.fosub_bridge is not doing what I expected. It forces you to sign up a form registration, that is not required for me now.

And, facebokId is not being persist. Although, every time I try to login, the provider creates a new user one, because it could not find anyone. I think I configured something wrong, but I could not find what it is...
Someone?

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    secured_area:
        pattern:    ^/
        anonymous: true
        logout: true
        oauth:
            resource_owners:
                facebook:           "/login/check-facebook"
            login_path:        /login
            use_forward:       false
            failure_path:      /login

            oauth_user_provider:
                service: hwi_oauth.user.provider.fosub_bridge

        logout:
            path: /logout


access_control:
    - { path: ^/, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }


hwi_oauth:
    connect:
        account_connector: hwi_oauth.user.provider.fosub_bridge
    fosub:
        username_iterations: 30
        properties:
            facebook:    facebookId
    firewall_names: [secured_area]

    resource_owners:
        facebook:
            type:                facebook
            client_id:           xxxxxxxxxxxxxxxx
            client_secret:       xxxxxxxxxxxxxx
            options:
                display: popup #dialog is optimized for popup window
                csrf: true

services:
    my.custom.user_provider:
        class:        AppBundle\Security\Core\User\MyFOSUBUserProvider
        arguments: ['@fos_user.user_manager', { facebook: facebook_id }]
@LaurentMarquet
Copy link

You may have a look at https://gist.github.com/danvbe/4476697 which helped me to achieve what you need (in particular the class FOSUBUserProvider.php

@soub4i
Copy link

soub4i commented May 14, 2017

in your arguments line i see " ` " try to remove it ; your line should looks like this
arguments: ['@fos_user.user_manager', { facebook: facebook_id }]

@fabionvs
Copy link
Author

Hello guys,
Danvbe FOSUBUserProvider.php was the best solution! Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants