2017 © Pedro Peláez
 

library xsolve-google-auth-bundle

XSolve Google Auth Bundle to provide signing in to FOSUserBundle with Google Auth

image

xsolve-pl/xsolve-google-auth-bundle

XSolve Google Auth Bundle to provide signing in to FOSUserBundle with Google Auth

  • Wednesday, April 8, 2015
  • by piotrpasich
  • Repository
  • 58 Watchers
  • 5 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

About

This bundle allows user to sign in via Google Auth 2.0 API to FOSUserBundle., (*1)

It includes:, (*2)

  • Google API integration
  • Creating new user when it's necessary
  • Signing in

Installation

1) Install and configure FOSUserBundle, (*3)

https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md

2) Add to composer.json, (*4)

"require": {
    "xsolve-pl/xsolve-google-auth-bundle": "1.0.*"
},

3) Install dependencies, (*5)

composer install

4) Run the bundle in app/AppKernel.php, (*6)

public function registerBundles()
{
    return array(
        // ...
        new Xsolve\GoogleAuthBundle\XsolveGoogleAuthBundle(),
    );
}

5) Add to routing.yml, (*7)

xsolve_google_auth:
    resource: "@XsolveGoogleAuthBundle/Controller/"
        type:     annotation
            prefix:   /

6) Register your service in https://code.google.com/apis/console/b/0/ an configure parameters.yml and add, (*8)

xsolve_google_auth:
    name: Xsolve test application
    client_id: "4429041xxxx.apps.googleusercontent.com"
    client_secret: "xrAbfJ7wmOBZbYU3TyDxxxxx"
    redirect_uri: "http://testapp.xsolve.pl/oauth2callback"
    dev_key: xsolvetestapplication

    success_authorization_redirect_url: _welcome
    failure_authorization_redirect_url: _welcome

    scopes:
       -  profile
       -  email

    autoregistration: false
    autoregistration_domains: []

7) Add access controls to security.yml, (*9)

access_control:
    - { path: ^/oauth2callback, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/googleauthlogin, role: IS_AUTHENTICATED_ANONYMOUSLY }

Usage

After configuring a bundle you can go to /oauth2callback page and the browser should redirect to google access page., (*10)

Configuration options

Configuration can be adjusted in app/config/config.yml, (*11)

xsolve_google_auth:
    name: Xsolve test application #name of application from google console
    client_id: "4429041xxxx.apps.googleusercontent.com" #client id of application from google console
    client_secret: "xrAbfJ7wmOBZbYU3TyDxxxxx" #client secret key of application from google console
    redirect_uri: "http://testapp.xsolve.pl/oauth2callback" #redirect uri of application from google console
    dev_key: xsolvetestapplication #your developmnent's application name from google console

    scopes: #data which application needs from google API
       -  profile
       -  email

    success_authorization_redirect_url: _welcome #url key inside Symfony where user should be redirected after successful sign in
    failure_authorization_redirect_url: _welcome #url key inside Symfony where user should be redirected after failure sign in

    autoregistration: false #true|false - if false than user will be registered into system automaticaly
    autoregistration_domains:  #array may be empty. If autoregistration is true you can allow to register users only from selected domains
       - xsolve.pl

Add this link to your Twig template to force login action with Google OAuth 2.0 :, (*12)

<a href="{{ path('xsolve_googleauth_googleauthorization_authorization') }}">Login with Google</a>

or, (*13)

<a href="{{ path('xsolve_googleauth_googleauthorization_authorization_1') }}">Login with Google</a>

The Versions

08/04 2015

dev-master

9999999-dev

XSolve Google Auth Bundle to provide signing in to FOSUserBundle with Google Auth

  Sources   Download

MIT

The Requires

 

04/11 2013

1.0.0.x-dev

1.0.0.9999999-dev

XSolve Google Auth Bundle to provide signing in to FOSUserBundle with Google Auth

  Sources   Download

MIT

The Requires