There is no license information available for the latest version (dev-main) of this package.

A security component for the Luminar framework.

dev-main 2024-08-30 13:16 UTC

This package is auto-updated.

Last update: 2025-04-14 11:44:26 UTC


README

Tests Status

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.