Skip to content
This repository has been archived by the owner on Dec 5, 2017. It is now read-only.
/ LiipOneallBundle Public archive

[DEPRECATED] Symfony2 Bundle to integrate oneall.com

Notifications You must be signed in to change notification settings

liip/LiipOneallBundle

Repository files navigation

UNMAINTAINED

This bundle is no longer maintained. Feel free to fork it if needed.

Introduction

This is still a work in progress!

This Bundle enables integration of the Oneall.com into Symfony2. The code is based on https://github.com/FriendsOfSymfony/FOSFacebookBundle

Please also refer to the Oneall documentation: http://docs.oneall.com/plugins/

Furthermore please also refer to the official documentation on security, especially for details on the configuration: http://symfony.com/doc/current/book/security.html

Build Status

Prerequisites

This version requires Symfony 2.1

Installation

  1. Add the following lines in your composer.json:
{
  "require": {
      "liip/oneall-bundle": "dev-master"
  }
}
  1. Run the composer to download the bundle
$ php composer.phar require liip/oneall-bundle
  1. Add this bundle to your application's kernel:
        // app/ApplicationKernel.php
        public function registerBundles()
        {
            return array(
                // ...
                new Liip\OneallBundle\LiipOneallBundle(),
                // ...
            );
        }
  1. Add the following routes to your application and point them at actual controller actions
        #application/config/routing.yml
        liip_oneall_check:
            pattern:  /login_check
        liip_oneall_logout:
            pattern:  /logout
        #application/config/routing.xml
        <route id="liip_oneall_check" pattern="/login_check" />
        <route id="liip_oneall_logout" pattern="/logout" />
  1. Configure the oneall service in your config (most of the information can be copied out of the oneall.com control panel):
        # application/config/config.yml
        liip_oneall:
            site_subdomain: my_subdomain
            site_public_key: my_not_so_secret_key
            site_private_key: my_s3cr3t_key
            social_links: [linkedin, facebook, github, twitter]
            default_firewall_name: main
            callback_path: /foo
        # application/config/config.xml
        <liip_oneall:api
            site_subdomain="my_subdomain"
            site_public_key="my_not_so_secret_key"
            site_private_key="my_s3cr3t_key"
            default_firewall_name="main"
            callback_path="/foo"
        >
              <social-links>linkedin</social-links>
              <social-links>facebook</social-links>
              <social-links>github</social-links>
              <social-links>twitter</social-links>
        </liip_oneall:api>
 > Note you only need to specify either ``default_firewall_name`` or ``callback_path``.
 The ``callback_path`` can either be a relative path or a route name.
  1. Add this configuration if you want to use the security component:
        # application/config/config.yml
        security:
            firewalls:
                public:
                    # since anonymous is allowed users will not be forced to login
                    pattern:   ^/.*
                    liip_oneall:
                        check_path: liip_oneall_check
                    anonymous: true
                    logout:
                        handlers: ["liip_oneall.logout_handler"]

            access_control:
                - { path: ^/secured/.*, role: [IS_AUTHENTICATED_FULLY] } # This is the route secured with liip_oneall
                - { path: ^/.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] }
 You have to add `/secured/` in your routing for this to work. An example would be...
            liip_oneall_secured:
                pattern: /secured/
                defaults: { _controller: AcmeDemoBundle:Welcome:index }
  1. Optionally define a custom user provider class and use it as the provider or define path for login. There is a default implementation for FOSUserBundle integration
        # application/config/config.yml
        security:
            providers:
                # choose the provider name freely
                my_liip_oneall_provider:
                    id: liip_oneall.user_provider   # see "Example Custom User Provider using the FOS\UserBundle" chapter further down

            firewalls:
                public:
                    pattern:   ^/.*
                    liip_oneall:
                        login_path: /login
                        check_path: liip_oneall_check
                        default_target_path: /
                        provider: my_liip_oneall_provider
                    anonymous: true
                    logout:
                        handlers: ["liip_oneall.logout_handler"]
  1. Optionally use access control to secure specific URLs
        # application/config/config.yml
        security:
            # ...
            
            access_control:
                - { path: ^/oneall/,           role: [ROLE_ONEALL] }
                - { path: ^/.*,                role: [IS_AUTHENTICATED_ANONYMOUSLY] }
The role `ROLE_ONEALL` has to be added in your User class (see Acme\MyBundle\Entity\User::setFBData() below).
> Note that the order of access control rules matters!

Setting up the JavaScript SDK

A templating Twig extension is included for loading the Oneall JavaScript SDK and initializing it with parameters from your service container. To setup the Oneall JavaScript environment, add the following to your layout just after the opening body tag:

<!-- inside a twig template -->
{{ oneall_initialize() }}

Include the login button in your templates

Just add the following code in one of your templates:

<!-- inside a twig template -->
{{ oneall_login_button({'login_container_id': 'some_tag_id'}) }}

Note that login_container_id is optional and defaults to oa_social_login_container.

Include the logut url in your templates

TODO