liberty_code / authentication_model
库
v1.0.0
2024-02-27 21:28 UTC
Requires
- php: ~7 || ~8
- liberty_code/authentication: ^1.0.
- liberty_code/library: ^1.0.
- liberty_code/model: ^1.0.
- liberty_code/validation: ^1.0.
This package is auto-updated.
Last update: 2024-09-27 22:36:02 UTC
README
描述
库包含认证模型组件,用于管理识别和认证系统。
要求
- 脚本语言:PHP:版本 7 || 8
框架库实现要求
库仓库:liberty_code/validation:版本 1.0
标准规则实现(或等效)
在实体上提供的验证器必须包含所有标准规则,这些规则已添加到其规则集合中。
验证器规则实现(或等效)
在实体上提供的验证器必须包含所有验证器规则,这些规则已添加到其规则集合中。每个验证器规则必须使用验证器,其实现与实体上提供的验证器相同。
安装
有几种可能的方式
Composer
要求
它需要Composer安装。更多信息: https://getcomposer.org.cn
命令:移动到项目根路径
cd "<project_root_path>"
命令:安装
php composer.phar require liberty_code/authentication_model ["<version>"]
注意
包含vendor
如果项目使用Composer,则必须包含vendor
require_once('<project_root_path>/vendor/autoload.php');
配置
安装命令允许在composer文件"
{ "require": { "liberty_code/authentication_model": "<version>" } }
包含
下载
- 下载以下仓库。
- 将其放在仓库根路径。
包含源代码
require_once('<repository_root_path>/include/Include.php');
使用
认证
认证实体允许使用实体设计认证类。
元素
AuthenticationEntity
扩展认证功能。使用实体设计认证类,以获取有关一个特定实体的所有识别和认证信息。
SecretAuthEntity
扩展认证实体功能。使用标识属性作为识别信息,使用秘密属性作为认证信息。
TokenAuthEntity
扩展认证实体功能。使用令牌属性作为识别和认证信息。
CredentialAuthEntity
扩展认证实体功能。使用凭证属性来检索标识符,作为识别信息,并使用秘密作为认证信息。
示例
// Get secret authentication entity
use liberty_code\authentication_model\authentication\secret\library\ConstSecretAuth;
use liberty_code\authentication_model\authentication\secret\model\SecretAuthEntity;
$secretAuthEntity = new SecretAuthEntity();
...
// Set identifier attribute
$secretAuthEntity->setAttributeValue(ConstSecretAuth::ATTRIBUTE_KEY_IDENTIFIER, '...');
...
// Set secret attribute
$secretAuthEntity->setAttributeValue(ConstSecretAuth::ATTRIBUTE_KEY_SECRET, '...');
...
// Get array of identification data
var_dump($secretAuthEntity->getTabIdData());
...
// Get array of authentication data
var_dump($secretAuthEntity->getTabAuthData());
...