2017 © Pedro Peláez
 

library authentication

A generic user authentication module for ZF2.

image

t4web/authentication

A generic user authentication module for ZF2.

  • Monday, September 5, 2016
  • by maxgu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 394 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 2 % Grown

The README.md

Authentication

Master: Build Status codecov.io Scrutinizer Code Quality, (*1)

Authentication module for zf2, (*2)

Contents

Introduction

Very simple authentication from the Box - define accounts config with login and password and use., (*3)

Installation

Main Setup

By cloning project

Clone this project into your ./vendor/ directory., (*4)

With composer

Add this project in your composer.json:, (*5)

"require": {
    "t4web/authentication": "~1.0.0"
}

Now tell composer to download Authentication by running the command:, (*6)

$ php composer.phar update

Post installation

Enabling it in your application.config.phpfile., (*7)

<?php
return array(
    'modules' => array(
        // ...
        'T4web\Authentication',
    ),
    // ...
);

Configuring

For define which page need authorization, you can redeclare need-authorization-callback, by default:, (*8)

'need-authorization-callback' => function(RouteMatch $match) {
    $name = $match->getMatchedRouteName();

    if ($name == 'auth-login') {
        return false;
    }

    if (strpos($name, 'admin') !== false) {
        return true;
    }

    return false;
},

For change auth login form layout you can define layout route param, for change redirect uri after success authorization, you can define redirect-to-url route param:, (*9)

'router' => array(
    'routes' => array(
        'auth-login' => array(
            'options' => array(
                'defaults' => array(
                    'layout' => 'layout/my_auth_layout',
                    'redirect-to-url' => '/some/uri',
                ),
            ),
        ),
    ),
),

By default auth use php array for auth storage, but you can write own:, (*10)

'service_manager' => [
    'factories' => [
        Zend\Authentication\Adapter\AdapterInterface::class => Adapter\MyAdapter::class,
    ]
]

Adapter\MyAdapter must implement Zend\Authentication\Adapter\ValidatableAdapterInterface., (*11)

Adapters

This module contain two adapters in the Box PhpArray and Table., (*12)

PhpArray adapter

This adapter use by default. For define logins and passwords just describe it in you config in auth-accounts section:, (*13)

'auth-accounts' => [
    'someUser1' => 'str0ngp@ssw0rd',
    'someUser2' => '111',
],

Table adapter

This is wrapper for Zend\Authentication\Adapter\DbTable\CallbackCheckAdapter, for start use, define it in your config:, (*14)

'service_manager' => [
    'factories' => [
        Zend\Authentication\Adapter\AdapterInterface::class => \T4web\Authentication\Adapter\TableFactory::class,
    ]
],

and describe auth['table-adapter'] config:, (*15)

'auth' => [
    'table-adapter' => [
        'table-name' => 'users',
        'identity-column' => 'email',
        'credential-column' => 'password',
    ],
],

Testing

Unit test runnig from authentication module directory., (*16)

$ codeception run unit

For running Functional tests you need create codeception.yml in you project root, like this:, (*17)

include:
    - vendor/t4web/authentication  # <- add authentication module tests to include

paths:
    log: tests/_output

settings:
    colors: true
    memory_limit: 1024M

After this you may run functional tests from your project root, (*18)

$ codeception run

The Versions

23/10 2015

1.0.0

1.0.0.0 https://github.com/t4web/Authentication

A generic user authentication module for ZF2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2

01/12 2014

0.0.2

0.0.2.0 https://github.com/t4web/Authentication

A generic user authentication module for ZF2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2

01/12 2014

0.0.1

0.0.1.0 https://github.com/t4web/Authentication

A generic user authentication module for ZF2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2