Skip to content

anthonysan95/url-signer

Repository files navigation

Create secured URLs with a limited lifetime

Latest Version on Packagist Software License Build Status Quality Score Total Downloads

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.

About

Simple URL Signer for securing your URLs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages