Giter Site home page Giter Site logo

ezsocialloginbundle's Introduction

Ez Social Login Bundle

Build StatusLatest Stable Version

The eZ Social Login Bundle adds support for authenticating users via OAuth1.0a or OAuth2 in eZ Platform.

It just uses HwiOauthBundle, so you can refer to this documentation bundle to know how it internally works.

Installation

You can install this project via composer:

composer require crevillo/ezsocialloginbundle

Documentation

You can use any of the social networks listed in HwiOauthBundle documentation. Please refer to that bundle in order to know how you can configure any of them.

Setting up this bundle

A) Add EzSocialLoginBundle to your project

composer require crevillo/ezsocialloginbundle:dev-master

B) Enable the bundle

Enable the bundle in the kernel, you will also need to enable HwiOauthBundle

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
        new Crevillo\EzSocialLoginBundle\CrevilloEzSocialLoginBundle()
    );
}

C) Import the routing

Import the redirect.xml and login.xml routing files in your own routing file.

# app/config/routing.yml
hwi_oauth_redirect:
    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
    prefix:   /connect

hwi_oauth_login:
    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    prefix:   /login

Note:

The bundle will override default user login template provided by EzPublishCoreBundle. It might happen that you won't see any changes if any of your others bundles does that too. So, if you already have a customized login template, just add these lines anywhere in your content block of your template.

D) Configure Google resource owner

You will need to modify your config.yml file adding

hwi_oauth:
    # list of names of the firewalls in which this bundle is active, this setting MUST be set
    firewall_names: [ezpublish_front]

Next, you can add your google app information and options under hwi_oauth > resource_owners settings

hwi_oauth:
    # list of names of the firewalls in which this bundle is active, this setting MUST be set
    firewall_names: [ezpublish_front]
    resource_owners:
        your_google_app:
            type: google
            client_id: <your client id>
            client_secret: <your client secret>
            scope: "email profile"

E) Configuring the Security Layer

The bundle needs a service that is able to load users based on the user response of the oauth endpoint. It should implement the interface: HWI\Bundle\OAuthBundle\Security\Core\User\OAuthAwareUserProviderInterface. This bundle provides this service as an starting point, but you are free to create your own.

Our UserProvider will try to get the username from the social network. If there as already any user in the eZ Platform repository with this username, it will just return it.

If there is no user having that username, it will try to create a new one under your "Guest Accounts" user group and will also log in it.

F) Configure the oauth firewall

In the firewall configuration you will need to configure a login path for the resource owners you have configured previously. Additionally you will need to point the oauth firewall to the service this bundle provides:

# app/config/security.yml
security:
    firewalls:
        # your other firewalls
        #
        ezpublish_front:
            anonymous: ~
            oauth:
                resource_owners:
                    google:             "/login/check-google"
                login_path:        /login
                use_forward:       false
                failure_path:      /login

                oauth_user_provider:
                    service:  crevillo.ezsocialloginbundle.oauth_aware.user_provider.service

Finally the paths you have defined in the previous step for your resource_owners must be adding to your routing.

# app/config/routing.yml
google_login:
    path: /login/check-google
  • Actually this is manually tested and seems to work for Facebook, Twitter, Google and Linkedin.

That's it!. Feel free to try any other social networks!.

ezsocialloginbundle's People

Contributors

andrerom avatar crevillo avatar declemo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

ezsocialloginbundle's Issues

Good job and very helpful!

Hi Crevillo,

we tested the bundle on a eZ 5.4.5 system /Symfony stack) and it works for this version as well!
What do you think regarding the dependencies which is 6 or higher right now. A version 5.4.5 or higher should work as well and it might make sense to lower the restrictions.
What do you think?

We were able to set it up for facebook with this configuration:
hwi_oauth: firewall_names: [ezpublish_front] resource_owners: facebook: type: facebook client_id: %facebook_id% client_secret: %facebook_secret% scope: "email" infos_url: "https://graph.facebook.com/me?fields=id,name,email" paths: email: email

There might be one issue with Facebook if you did not have published your app yet since in this case no email is provided by facebook (unless you use a test user). In this case creating the user fails with an exception. It might be usefull to add checks (i am not sure if other providers might return an empty email even after a successful login).

Greetings from Berlin!

Update HWIOAuthBundle version

Hi,

You are using HWIOAuthBundle version 0.4

Version 0.5.3 is now available.

I need to use the office365 ressource owner but it is not available on version 0.4

Is it posible to update the version?

Thanks, Vincent

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.