anthonysan95 / url-signer
Simple URL Signer for securing your URLs
Requires
- php: ^7.2
- illuminate/support: ^5.7
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2025-06-15 02:28:09 UTC
README
This package can create URLs with or without a limited lifetime. This is done by adding an expiration date and a signature to the URL.
$urlSigner = new UrlSigner(); $urlSigner->setKeyResolver(function() { return 'randomKey'; }); $signedUrl = $urlSigner->sign('https://myapp.com', [ 'api_token' => 'aisj2jifeji3i' ]); echo $signedUrl; // => The generated url will be always valid // => This will output an URL that looks like 'https://myapp.com/?api_token=aisj2jifeji3i&signature=xxxx'. $signedUrl = $urlSigner->temporarySign('https://myapp.com', 30); echo $signedUrl; // => The generated url will be valid for 30 days // => This will output an URL that looks like 'https://myapp.com/?expires=xxxx&signeture=xxxx'
The signature will be generated using the sha256
algorithm.
Imagine mailing this URL out to the users of your application. When a user clicks on a signed URL your application can validate it with:
$urlSigner->validate('https://myapp.com/?expires=xxxx&signature=xxxx');
Installation
The package can installed via Composer:
composer require anthonysan95/url-signer
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please make an issue in the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.