frumbert / coursesuitevalidator
该软件包最新版本(dev-master)没有可用的许可信息。
CourseSuite API 验证器
dev-master
2020-12-11 03:05 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-09-11 11:41:20 UTC
README
在最简单的形式中,此类查看 "token" 或 "apikey" 的值,并将其与通过环境变量在 web 服务器中设置的配置服务器进行验证。
composer require frumbert/coursesuitevalidator
然后确保 web 服务器(或主机脚本)设置这些环境变量
HOME_URL https://www.your-app-domain.com/
AUTHAPI_URL https://www.coursesuite.ninja/api/validate/your-app-name/{hash}/
AUTHAPI_USER (digest-username)
AUTHAPI_PASSWORD (digest-password)
{hash} 值将被查询字符串提供的 "hash" 值进行字符串替换
然后是代码
require '../vendor/autoload.php';
$verifier = (new CoursesuiteValidator(false,true))->Validate($_GET);
if ($verifier->licence->remaining < 1) {
header("location: " . $verifier->home . "in-use");
die();
}
if ($verifier->licence->tier < 1) {
header("location: " . $verifier->home . "bad-tier");
die();
}
if (!$verifier->is_valid()) {
die("authentication failed or was not understood.");
}
// include "rest_of_app.php";
作为 PHP 对象返回(默认值)
{
valid: false,
licence: {
tier: 0,
seats: 1,
remaining: 1
},
code: {
minified: true,
debug: false
},
api: {
bearer: null,
publish: "",
header: {
html: "",
css: ""
},
template: ""
},
user: {
container: "",
email: ""
},
addons: [],
home: ""
}