luminar-organization / security
A security component for the Luminar framework.
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: 2025-04-14 11:44:26 UTC
README
Luminar Security is a PHP library designed to provide a comprehensive set of security utilities and components for building secure web applications. It includes modules for authentication, encryption, hashing, protection against common web vulnerabilities, and more.
Features
- Authentication: Form Login, access tokens, login link, and utility functions.
- Encryption: Support for AES256, Base64, RSA, and XOR encryption methods.
- Hashing: Provides multiple hashing algorithms like Argon2i, Argon2id, Bcrypt, Hmac, MD5, SHA1, and SHA256
- Protection: Protection against CSRF, XSS, XML attacks, ClickJacking.
- Exceptions: Custom exceptions for handling security-related errors.
Installation
To install the Luminar Security library, you can use Composer:
composer require luminar-organization/security
Usage
Authentication
Example of using form-based authentication
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);
Encryption
Example of encrypting data with 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);
Testing
The library includes a comprehensive set of tests to ensure its security features are working correctly. To run the tests, use PHPUnit:
composer run test
Contributing
Checkout our core repository CONTRIBUTING.md
License
This project is licendes under the MIT License - se the License file for details
Support
If you have any questions or need help, feel free to open an issue in the GitHub Repository.