2 Star 2 Fork 1

深圳市赛雅科技有限公司 / 壹写作出版商开放平台

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
baseauth.php 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Rain 提交于 2018-09-08 11:44 . 1. 完善获得 ewr文件及部分解析
<?php
/**
* 验证用户请求的合法性
* appid 传入的APPID,需与本地一一对应
* timestamp 传入的时间戳
* signture 传入的加密签名,通过MD5计算后与本地的加密签名进行验证
*/
class BaseAuth implements iAuthenticate
{
public function __isAuthenticated()
{ //验证appid 签名
if (!empty($_GET['appid']) && !empty($_GET['timestamp']) && !empty($_GET['signture'])) {
if (APP_ID != $_GET['appid']) { //传入的appid与系统中的不一致
throw new RestException(401, '不正确的APPID!');
}
//根据appid和appsecret和时间戳加密的签名验证有效性
$signture = md5($_GET['appid'] . APP_SECREAT . $_GET['timestamp']);
if ($signture == $_GET['signture']) { //签名验证正确
return true;
} else {
throw new RestException(401, '签名错误!' . $signture);
}
}
throw new RestException(401, '参数传递错误!');
}
}
PHP
1
https://gitee.com/xiezuo/ewpub.git
git@gitee.com:xiezuo/ewpub.git
xiezuo
ewpub
壹写作出版商开放平台
master

搜索帮助