luminar-organization / security
此软件包的最新版本(dev-main)没有可用的许可信息。
Luminar 框架的安全组件。
dev-main
2024-08-30 13:16 UTC
Requires
- php: >=8.2
- ext-dom: *
- ext-libxml: *
- ext-openssl: *
- luminar-organization/core: dev-main
- luminar-organization/database: dev-main
- luminar-organization/http: dev-main
Requires (Dev)
- ext-pdo: *
- phpstan/phpstan: 2.0.x-dev
- phpunit/phpunit: >=11.3.1
- vimeo/psalm: ^6.0@dev
This package is auto-updated.
Last update: 2024-09-14 10:33:13 UTC
README
Luminar Security 是一个 PHP 库,旨在提供一套全面的网络安全工具和组件,用于构建安全的 Web 应用程序。它包括身份验证、加密、哈希、防范常见 Web 漏洞等模块。
特性
- 身份验证:表单登录、访问令牌、登录链接和实用函数。
- 加密:支持 AES256、Base64、RSA 和 XOR 加密方法。
- 哈希:提供多种哈希算法,如 Argon2i、Argon2id、Bcrypt、Hmac、MD5、SHA1 和 SHA256。
- 保护:防范 CSRF、XSS、XML 攻击和 ClickJacking。
- 异常:自定义异常处理安全相关错误。
安装
要安装 Luminar Security 库,您可以使用 Composer
composer require luminar-organization/security
使用方法
身份验证
基于表单的身份验证示例
use Luminar\Security\Authentication\FormLogin; use Luminar\Core\Config\Config; use Luminar\Http\Request; use Luminar\Http\Managers\SessionManager; use Luminar\Database\Connection\Connection; $connection = new Connection("mysql:host=localhost;dbname=luminar-test", 'root'); $config = new Config("PATH TO YOUR CONFIGS LOCATION"); $sessionManager = new SessionManager(); $request = new Request(); // Form Login can throw these exceptions: // - ConfigException (invalid configuration) // - InvalidCredentials (invalid credentials) // - SuccessAuthentication (on success) new FormLogin($request, $config, $sessionManager, $connection);
加密
使用 AES256 加密数据的示例
use Luminar\Security\Encryption\AES256; $AES256 = new AES256(); $data = "Hello World!"; $secretKey = 'my_secret_key'; $secretVi = 'my_secret_vi'; $encrypted = $AES256->encrypt($data, $secretKey, $secretVi); $decrypted = $AES256->decrypt($encrypted, $secretKey, $secretVi);
测试
该库包含一套全面的测试,以确保其安全特性正确工作。要运行测试,请使用 PHPUnit
composer run test
贡献
请查看我们的 核心仓库 CONTRIBUTING.md
许可
本项目采用 MIT 许可协议 - 详细信息请参阅 许可文件
支持
如果您有任何问题或需要帮助,请随时在 GitHub 仓库中提交问题。