定制 dilsonjlrjr/slim3-auth 二次开发

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

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

dilsonjlrjr/slim3-auth

Composer 安装命令:

composer require dilsonjlrjr/slim3-auth

包简介

Slim Auth

README 文档

README

Module Auth Slim 3

Installation:

You can install the library directly from composer / packagist:

$ composer require "dilsonjlrjr/slim3-auth"

Dependencies:

Usage:

The slim3 -auth uses three components in your authentication process:

  • Adapter
  • AuthResponse
  • FacadeAuth

Adapters:

The adaptares are responsible for defining the authentication rules. Every adapter implements AuthAdapterInterface interface and uses its constructor as input. All adapter should return a type AuthResponse object. Below an adapter instance.

use SlimAuth\AuthResponse;
use SlimAuth\AuthAdapterInterface;

class AuthTestAdapter implements AuthAdapterInterface
{

    private $username;

    private $password;

    /**
     * AuthTestAdapter constructor.
     * Data entry
     * @param string $username
     * @param string $password
     */
    public function __construct(string $username, string $password)
    {
        $this->username = $username;
        $this->password = $password;
    }

    function authenticate() : AuthResponse
    {
        if ($this->username == 'username' && $this->password == 'password') {
            return new AuthResponse(AuthResponse::AUTHRESPONSE_SUCCESS, 'User auth success', 'Slim3Auth', [ 'id' => 1010 ]);
        }

        return new AuthResponse(AuthResponse::AUTHRESPONSE_FAILURE, 'Failure');
    }

}
Adapters - Methods

authenticate

Define:
	Authenticates according to the rules defined in the implemented class
Params:
	no params;
Return:
	SlimAuth\AuthResponse

AuthResponse

The AuthResponse class indicates the result of the authentication process. It has constants that define states, AUTHRESPONSE_SUCCESS (Successful authentication), AUTHRESPONSE_FAILURE (Authentication failed).

AuthResponse - Methods

__construct

Define:
	Set message result autenticate
Params:
	$code [int] - AUTHRESPONSE_SUCCESS or AUTHRESPONSE_FAILURE;
	$message [string] - Defined user. Message result authentication;
	$keyAttributeSession [string] - Key used for session rescue;
	$attributesSession [array] - Array with attributes session;
Return:
	no returns;

setMessage

Define:
	Set message result autenticate
Params:
	$code [int] - AUTHRESPONSE_SUCCESS or AUTHRESPONSE_FAILURE;
	$message [string] - Defined user. Message result authentication;
	$keyAttributeSession [string] - Key used for session rescue;
	$attributesSession [array] - Array with attributes session;
Return:
	no returns;

getMessage

Define:
	Get array message
Params:
	no params;
Return:
	no returns;
Example:
	[
		$code, [int]
		$message, [string]
		$keyAttributeSession, [string]
		$attributesSession, [array]
	]

FacadeAuth:

This facade runs an adapter set in advance and stored in session attributes set by the adapter.

FacadeAuth - Methods

__construct

Define:
	The class constructor
Params:
	$authAdapter [SlimAuth\AuthAdapterInterface] - implemented adapter interface SlimAuth\AuthAdapterInterface;
	$session [RKA\Session] - Stored Session

Return:
	no returns;

auth

Define:
	Auth method
Params:
	no params;
Return:
	no returns;

isValid

Define:
	It indicates whether the authentication was valid
Params:
	no params;
Return:
	boolean;

Contact:

Email: dilsonjlrjr@gmail.com

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固