2017 © Pedro Peláez
 

library hybridauth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

image

org_heigl/hybridauth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  • Saturday, July 21, 2018
  • by heiglandreas
  • Repository
  • 6 Watchers
  • 20 Stars
  • 1,594 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 3 Open issues
  • 13 Versions
  • 2 % Grown

The README.md

OrgHeiglHybridAuth

Join the chat at https://gitter.im/heiglandreas/HybridAuth, (*1)

Build Status Code Climate Scrutinizer Code Quality Codacy Badge Coverage Status, (*2)

Dependency Status Total Downloads Latest Stable Version Stories in Ready, (*3)

Use the SocialConnect-Library to create an absolute lightweight Authentication-Layer for your ZendFramework3-App, (*4)

You can login with all supported SocialNetwork-Logins. The network and a user-object holding id, name, mail and language will be stored in the session. If you already have SocialNetwork users in your application you can use these to authorize your users., (*5)

Requirements

  • The SocialConnect-Library. This lib uses the version 3 which is not (yet) stable!
  • Zend Framework3 (well, obvious, isn't it?)

Usage

  1. In your application.conf-file add the Module to the list of modules
  2. Copy the file vendor/org_heigl/hybridauth/config/autoload/module-orgHeiglHybridAuth.local.php to your applications config/autoload-directory and adapt as appropriate. That might look like this:, (*6)

    return [
        'OrgHeiglHybridAuth' => [
            'socialAuth' => [
                'redirectUri' => 'http://localhost:8080/authenticate/backend',
                'provider' => [
                    'twitter' => [
                        'applicationId' => '',
                        'applicationSecret' => '',
                        'scope' => ['email'],
                    ],
                    'github' => [
                        'applicationId' => '',
                        'applicationSecret' => '',
                        'scope' => ['email'],
                    ],
                ],
            ],
            'session_name' => 'orgheiglhybridauth',
            'backend'         => array('Twitter'), // could also be ['Twitter', 'Facebook']
            // 'link'            => '<a class="hybridauth" href="%2$s">%1$s</a>', // Will be either inserted as first parameter into item or simply returned as complete entry
            // 'item'            => '<li%2$s>%1$s</li>',
            // 'itemlist'        => '<ul%2$s>%1$s</ul>',
            // 'logincontainer'  => '<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">%1$s<b class="caret"></b></a>%2$s</li>',
            // 'logoffcontainer' => '<li>%1$s</li>',
            // 'logoffstring'    => 'Logout %1$s',
            // 'loginstring'     => 'Login%1$s',
            // 'listAttribs'     => null, // Will be inserted as 2nd parameter into item
            // 'itemAttribs'     => null, // Will be inserted as 2nd parameter into itemlist
        ]
    ];
    
  3. Add this snippet to create a login-link, (*7)

    <?php
    $provider = "Twitter";
    echo $this->hybridauthinfo($provider);
    ?>
    
  4. After login you can access the user-info the following way:, (*8)

    $config = $this->getServiceLocator()->get('Config');
    $config = $config['OrgHeiglHybridAuth'];
    $hybridAuth = new Hybridauth($config['hybrid_auth']);
    
    $token = $this->getServiceLocator()->get('OrgHeiglHybridAuthToken');
    if (! $token->isAuthenticated()) {
        echo 'No user logged in';
    }
    /** @var OrgHeiglHybridAuth\UserToken $user */
    echo $token->getDisplayName(); // The name of the logged in user
    echo $token->getUID();  // The internal UID of the used service
    echo $token->getMail(); // The mail-address the service provides
    echo $token->getLanguage(); // The language the service provides for the user
    echo $token->getService()  // Should print out the Name of the service provider.
    

Installation

composer

This module is best installed using composer. For that, run the following command to add the library to your app:, (*9)

# Require the hybridauth-module
composer require org_heigl/hybridauth

If you want to use more than one authentication-provider you should instead run this:, (*10)

# Require the hybridauth-module
composer require org_heigl/hybridauth:dev-feature/multipleProviders

Manual installation

So you want it the hard way? Sure you don't want to give composer a try?, (*11)

Then go figure it out. You might want to ask on the gitter channel or on IRC (freenode) but expect a reply along the line "use composer!", (*12)

Note that you can either download the zip-files of the libraries or use the git submodule command to clone the libs into the appropriate folders. You should not simply use git clone <library> <target> as that might interfere with your local git-repo (when you use one). The submodule approach makes Lib-updates easier bun can end in a lot of headaches due to the caveats of the submodule-command! I can not provide you with support in that case! Alternatively you can fork the project at github., (*13)

Example Implementation.

There is an example-implementation at https://hybridauth.heigl.org - The sourcecode is on github., (*14)

The Versions

21/07 2018
15/02 2017
07/02 2017

dev-feature/addCurrentZF

dev-feature/addCurrentZF http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

The Development Requires

user zf2 module login facebook twitter github social network

10/05 2016

1.x-dev

1.9999999.9999999.9999999-dev http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

user zf2 module login facebook twitter github social network

10/05 2016

1.0.4

1.0.4.0 http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

user zf2 module login facebook twitter github social network

10/05 2016

2.0.0

2.0.0.0 http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

The Development Requires

user zf2 module login facebook twitter github social network

10/05 2016

1.0.2

1.0.2.0 http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

user zf2 module login facebook twitter github social network

23/04 2015

1.0.1

1.0.1.0 http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

user zf2 module login facebook twitter github social network

23/04 2015

dev-hotfix/currentLibs

dev-hotfix/currentLibs http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

user zf2 module login facebook twitter github social network

11/10 2013

v1.0.0

1.0.0.0 http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

user zf2 module login facebook twitter github social network

20/05 2013

dev-travis

dev-travis http://github.com/heiglandreas/HybridAuth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

  Sources   Download

MIT

The Requires

 

user zf2 module login facebook twitter github social network