定制 pmill/php-auth 二次开发

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

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

pmill/php-auth

最新稳定版本:0.2.3

Composer 安装命令:

composer require pmill/php-auth

包简介

A simple authentication library

README 文档

README

Build Status Code Climate Test Coverage Test Coverage

Introduction

This package contains a simple framework agnostic PHP authentication library.

Installation

Installing via Composer

The recommended way to install php-auth is through Composer.

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest version of php-auth:

composer.phar require pmill/php-auth

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Usage

Implement the AuthUser interface on your existing user class. Make sure when you set the user's password, you hash it first.

class User implements \pmill\Auth\Interfaces\AuthUser
{
    public function setPassword($password)
    {
        $passwordHelper = new \pmill\Auth\Password;
        $this->password = $passwordHelper->hash($password);
    }
    
    /**
     * The rest of your user class
     */
}

Create your user instance

$user = new User();
$user->setId(1);
$user->setUsername('username');
$user->setPassword('password');

Attempt the login

$auth = new \pmill\Auth\Authenticate;

try {
    $auth->login($user, 'password');
    echo 'login succeeded';
}
catch(\pmill\Auth\Exceptions\PasswordException $e) {
    echo 'login failed, incorrect password';
}

Version History

0.2.3 (30/05/2015)

  • Added customisable session key

0.2.2 (25/05/2015)

  • Separated out the two factor authentication code in Authentication.php into a separate injectable class

0.2.1 (24/05/2015)

  • Fixed a bug where we were coding against the implementation of PasswordHelper rather than the interface

0.2.0 (23/05/2015)

  • Separated Auth class into Authentication and Password

0.1.1 (23/05/2015)

  • Added unit tests

0.1.0 (22/05/2015)

  • First public release of php-auth

Copyright

php-auth Copyright (c) 2015 pmill (dev.pmill@gmail.com) All rights reserved.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-22