Developed with love by KnpLabs Hire us for your project!
28

LiipOneallBundle

by liip

Symfony2 Bundle to integrate oneall.com

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"
    }
    }

  2. Run the composer to download the bundle
    bash
    $ php composer.phar require liip/oneall-bundle

  3. Add this bundle to your application's kernel:
    php
    // app/ApplicationKernel.php
    public function registerBundles()
    {
    return array(
    // ...
    new Liip\OneallBundle\LiipOneallBundle(),
    // ...
    );
    }

  4. Add the following routes to your application and point them at actual controller actions
    yaml
    #application/config/routing.yml
    liip_oneall_check:
    pattern: /login_check
    liip_oneall_logout:
    pattern: /logout

    xml
    #application/config/routing.xml
    <route id="liip_oneall_check" pattern="/login_check" />
    <route id="liip_oneall_logout" pattern="/logout" />

  5. Configure the oneall service in your config (most of the information can be copied out of the oneall.com control panel):
    yaml
    # 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

    xml
    # 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.

  6. 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 }
    
  7. 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"]
    
  8. 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:
html+jinja
<!-- inside a twig template -->
{{ oneall_initialize() }}

Include the login button in your templates

Just add the following code in one of your templates:
html+jinja
<!-- 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

Copyright (c) Liip AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
liip_oneall:
site_subdomain: ~ # Required
site_public_key: ~ # Required
site_private_key: ~ # Required
callback_path: ~
default_firewall_name: ~
alias: ~
class:
api: Liip\OneallBundle\Oneall\OneallApi
twig: Liip\OneallBundle\Twig\Extension\OneallExtension
fosuserbundle_provider: Liip\OneallBundle\Security\User\UserProvider
social_links: []
  • minor tweak
    By lsmith77, 3 years ago
  • ws fix
    By lsmith77, 3 years ago
  • add branch alias
    By lsmith77, 3 years ago
  • Merge pull request #6 from d-skora/master
    By lsmith77, 3 years ago
  • fix test setup
    By lsmith77, 3 years ago
  • Update OneallApi.php
    By d-skora, 3 years ago
  • Merge pull request #5 from liip/symfony_2_2
    By lsmith77, 3 years ago
  • made the bundle compatible with 2.2
    By lsmith77, 3 years ago
  • Bundle is only compatible with 2.1 as there is a BC break in 2.2 in the AuthenticationException signature
    By lsmith77, 3 years ago
  • Added missing parameter for extra information in exception
    By triggertoo, 3 years ago
  • Allow to update user when there is no oneallid
    By triggertoo, 3 years ago
  • Add name for flash messages
    By triggertoo, 3 years ago
  • Add method to post data to oneall
    By triggertoo, 3 years ago
  • tweaked travis setup
    By lsmith77, 3 years ago
  • removed todo comment
    By lsmith77, 3 years ago
  • fixed tests
    By lsmith77, 3 years ago
  • fixed exception creation
    By lsmith77, 3 years ago
  • Fix missing oneallid problem when refreshing user
    By triggertoo, 3 years ago
  • cosmetics
    By lsmith77, 3 years ago
  • some cleanups in configuration and documentation
    By lsmith77, 3 years ago
  • -Avoid to use session as a class var -Set oneallid on every request
    By triggertoo, 3 years ago
  • Create new user/update user with new data from oneall
    By triggertoo, 3 years ago
  • Add missing \" to fix xml error
    By triggertoo, 3 years ago
  • more refactoring, added a FOSUserBundle integration provider
    By lsmith77, 3 years ago
  • Update README.md
    By lsmith77, 3 years ago
  • Update README.md
    By lsmith77, 3 years ago
  • updated copyright (is this the right way to do this?)
    By lsmith77, 4 years ago
  • trying to prevent fatals in the test suite
    By lsmith77, 4 years ago
  • removed duplicate tag
    By lsmith77, 4 years ago
  • minor tweaks
    By lsmith77, 4 years ago