meta-tech/pws-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

meta-tech/pws-auth

Composer 安装命令:

composer require meta-tech/pws-auth

包简介

PwsAuth is an authentication protocol throught http header designed to web services

README 文档

README

PwsAuth is an authentication protocol throught http header designed to web services

Request Headers

Request headers must be define as follow :

Pws-Authorization : $type $token
Pws-Ident : $userkey

The $token can be either a loginToken or a sessionToken

The $token is divided in four part

  • a datetime formatted with the Authenticator::DATE_FORMAT format
  • an obfuscate part 's token builded by date, common salt & the third token 's part
  • a loginToken representing a user signed token for a specific login at given date OR a session token representing the session id
  • noise data to be removed

The complete token is valid only if obfuscate part can be rebuild.
This simple mecanism ensure that sessionId is valid and can be safety load

Authenticator 's configuration comes with a hash.session.index and hash.noise.length values wich can be redefined to move the session token part into the complete token

                                                    << hash.session.index >>                             << hash.noise.length >>
|-----------------------------------------------------------<<-^->>---------------------------------------------<<-^->>--------|
|- type ||-- date ---|------------ obfuscate token ---------<<-^->>-------------- session token ----------------<<-^->> noise -|
|       ||     1     |                    2                    |                         3                         |     4     |
 PwsAuth2 242003031711e1a6104135f04c6c01e6cd5952ecafbb53c928603b0gb64tqo609qse6ovd7lhdvk4fnaqk7cdl26e4d4qh7jb41eu5f1zb5y79m8pgu3

Requirements

PHP >= 5.4

Install

The package can be installed using Composer .

composer require meta-tech/pws-auth

Or add the package to your composer.json.

"require": {
    "meta-tech/pws-auth" : "^2.1"
}

Authenticator instanciation

<?php
require_once(__dir__ . '/vendor/autoload.php');

use Symfony\Component\Yaml\Yaml;
use MetaTech\PwsAuth\Authenticator;

$config        = Yaml::parse(file_get_contents(__dir__ . '/config/pwsauth.yml'));
$authenticator = new Authenticator($config);

ClientSide

A request header can be generated via the generateHeader($login, $key, $sessid=null) method.
The third parameter determine wich kind of token will be generated

for a client usage, see  MetaTech\Ws\Client

ServerSide

The Token can be retriew via the getToken method

loginToken is validate by the check(Token $token = null, $login) method
loginToken must match a public url with method POST and a couple of login/password
On successfull login, the session id must be transmit to the client.

sessionToken is valid only if the session can effectively be loaded, and the user key match the given Pws-Ident value

for a server usage, see MetaTech\Silex\Ws\Authentication and meta-tech/pws-server .

Configuration

Configuration must be the same on server and client sides
Hash definition is a convenient way to obfuscate your tokens

config/pwsauth.yml

type    : PwsAuth2

header  :
    auth            : Pws-Authorization
    ident           : Pws-Ident

salt    : 
    common          : jK5#p9Mh5.Zv}
    # used for generating user specific salt
    user.index      : 10
    user.length     : 12

hash    :
    sep             : /
    algo            : sha256
    # effective token length size. out of bound data is simply noise
    length          : 52
    # session index (or obfuscate length)
    session.index   : 58
    # ending noise data length)
    noise.length    : 12

Notes

A valid $userkey alone is useless
A valid $sessionId alone is useless

License

The project is released under the MIT license, see the LICENSE file.

meta-tech/pws-auth 适用场景与选型建议

meta-tech/pws-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.49k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「http」 「Authentication」 「webservice」 「protocol」 「PwsAuth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 meta-tech/pws-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 meta-tech/pws-auth 我们能提供哪些服务?
定制开发 / 二次开发

基于 meta-tech/pws-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-15