定制 t4web/authentication 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

t4web/authentication

Composer 安装命令:

composer require t4web/authentication

包简介

A generic user authentication module for ZF2.

关键字:

README 文档

README

Master: Build Status codecov.io Scrutinizer Code Quality

Authentication module for zf2

Contents

Introduction

Very simple authentication from the Box - define accounts config with login and password and use.

Installation

Main Setup

By cloning project

Clone this project into your ./vendor/ directory.

With composer

Add this project in your composer.json:

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

Now tell composer to download Authentication by running the command:

$ php composer.phar update

Post installation

Enabling it in your application.config.phpfile.

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

Configuring

For define which page need authorization, you can redeclare need-authorization-callback, by default:

'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:

'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:

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

Adapter\MyAdapter must implement Zend\Authentication\Adapter\ValidatableAdapterInterface.

Adapters

This module contain two adapters in the Box PhpArray and Table.

PhpArray adapter

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

'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:

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

and describe auth['table-adapter'] config:

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

Testing

Unit test runnig from authentication module directory.

$ codeception run unit

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

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

$ codeception run

统计信息

  • 总下载量: 414
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-08-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固