鸽子 / 安全
PHP 的鸽子安全库
1.0.0
2022-03-18 15:59 UTC
Requires
- codercat/jwk-to-pem: 1.1
- firebase/php-jwt: 6.0
This package is auto-updated.
Last update: 2024-09-24 20:14:46 UTC
README
用于使用鸽子 PaaS 安全功能的库
安装
composer require piges/security
使用方法
使用认证
<?php use Piges\Auth\AuthFilter; use Piges\Auth\AuthenticationHolder; try { AuthFilter::filter(); $user = Array( 'id' => AuthenticationHolder::getAuthentication()->getId(), 'authorities' => AuthenticationHolder::getAuthentication()->getAuthorities() ); } catch (\Throwable $th) { echo "Error in authentication: " + $th->getMessage(); }
使用 UCP
<?php use Piges\Auth\AuthFilter; use Piges\Ucp\UcpFilter; use Piges\Ucp\UcpHolder; try { AuthFilter::filter(); UcpFilter::filter(); $user = Array( 'tenant' => UcpHolder::getUcp()->getTenant()->getName(), 'eopoos' => UcpHolder::getUcp()->getEopoos(), 'permissions' => UcpHolder::getUcp()->getPermissions() ); } catch (\Throwable $th) { echo "Error in authentication or in ucp: " + $th->getMessage(); }