Zend Framework 2

PixelPin Auth

Updated June 30th 2017

Step-by-step installation guide

This tutorial is based off the Zend Framework 2.x MVC Skeleton Application.

PixelPin Auth is a Zend Framework 2 Module for authenticating with PixelPin using the Oauth2 API.

PixelPin Auth allows you to connect your website to PixelPin and let users authenticate using passwordless pictures. With PixelPin Auth module your user's can log in to your website using their PixelPin pictures. With PixelPin Auth, user's will no longer need to complete numerous forms for a successful registration.

To complete the installation, you'll need to create your PixelPin developer account.

Download the Zend Framework 2.x MVC Skeleton Application

Downloading an example website allows you to understand how to install PixelPin Auth into a Zend Framework 2 website. The knowledge you'll learn from installing the module will allow you to install the module onto your own website.

Click on the link to find a guide on how to Download and install the Zend Framework 2.x MVC Skeleton Application.

Installation

  1. From your Zend website's root directory, run composer require pixelpinplugins/pixelpin-auth in your favourite CLI. The output should look something like this:

Configuring the plugin

  1. Next you'll need to create a table in your database. Go to vendor/pixelpinplugins/pixelpin-zfc-user/data and open your preferred .sql file and run the query in your DB.

  2. Next you'll need to create another table in your database. Go to vendor/pixelpinplugins/pixelpin-auth/data and open your preferred .sql file and run the query in your DB.

  3. Next go your your config/application.config.php file and add the following modules to the module array:

  4. Next go to vendor/pixelpinplugins/pixelpin-auth/config/exampleautoload folder. This folder shows you what you need in your config/autoload folder. If you want, you can copy everything in this folder over to your config/autoload folder, but if you have these exact files already in your config/autoload just copy the contents of the file into that existing file (e.g. copy the content in global.php.dist to global.php).

  5. Open config/autoload/database.local.php and type your database details into the dbParams array at the top of the page and save the file.

  6. Open config/autoload/global.php.dist and copy the contents of the return array into the return array in config/autoload/global.php and save the file.

  7. Staying in config/autoload/global.php, you'll need to insert your zend framework 2 website's Client ID and Client Secret acquired from PixelPin. You'll need the Redirect URI to create a developer account to get your Client ID and Client Secret. Your redirect uri will be, for example, http(s)://local.zend.co.uk/pixelpin-auth/hauth?hauth.done=PixelPin. If you haven't created a PixelPin developer account before, a guide can be found here to guide you through the steps to create a PixelPin developer account.

  8. Next go to config/autoload/scn-social-auth.global.php and set 'pixelpin_enabled' to equal true.

  9. Next in your module/application/view/layout/layout.phtml (based on the default layout.phtml) enter the following code in your nav bar:

    <?php echo $this->navigation('navigation')->menu()->setUlClass('nav navbar-nav'); ?>

    So it'll look something like this:

  10. The module is now installed.

Additional Information

Click here to find out how you can add the PixelPin logo to the SSO button.

Testing the module

Log in/Register page

An example of a login/register page. Once you click this button it will redirect you to the PixelPin login page, once the user authenticates it will redirect to the 'logged in' page.

Example logged in page

This is an example of a logged in page. The code for this page can be found in vendor/pixelpinplugins/pixelpin-zfc-user/view/zfc-user-pixelpin/user/index.phtml. Index.phtml contains the logic to retrieving the user data as well as the code for the logout button.

Contributing

PixelPin Auth is an open-source project that allows developers using PixelPin to improve the plugin. You can find the links to the modules repo's below:

  1. PixelPin Auth
  2. PixelPin HybridAuth
  3. ZFC PixelPin Base
  4. ZFC PixelPin User