{"id":19324864,"url":"https://github.com/spatie/url-signer","last_synced_at":"2025-05-15T07:07:31.636Z","repository":{"id":36236365,"uuid":"40540701","full_name":"spatie/url-signer","owner":"spatie","description":"Create and validate signed URLs with a limited lifetime","archived":false,"fork":false,"pushed_at":"2025-02-14T13:00:51.000Z","size":122,"stargazers_count":429,"open_issues_count":0,"forks_count":48,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-04-14T12:59:10.506Z","etag":null,"topics":["mail","php","security","sign","url"],"latest_commit_sha":null,"homepage":"https://freek.dev/248-url-signing-in-laravel","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"spatie"}},"created_at":"2015-08-11T12:35:30.000Z","updated_at":"2025-04-04T04:41:10.000Z","dependencies_parsed_at":"2023-12-06T12:24:38.376Z","dependency_job_id":"b91914c2-511d-49bd-ab29-b446d81f0f6d","html_url":"https://github.com/spatie/url-signer","commit_stats":{"total_commits":99,"total_committers":18,"mean_commits":5.5,"dds":0.4949494949494949,"last_synced_commit":"356b70785cd2ad7e5148263025ac0f3f374d58f1"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Furl-signer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Furl-signer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Furl-signer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Furl-signer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/url-signer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292043,"owners_count":22046426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mail","php","security","sign","url"],"created_at":"2024-11-10T02:07:16.069Z","updated_at":"2025-05-15T07:07:26.627Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie"],"categories":[],"sub_categories":[],"readme":"# Create signed URLs with a limited lifetime\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/url-signer.svg?style=flat-square)](https://packagist.org/packages/spatie/url-signer)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/url-signer.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/url-signer)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/url-signer.svg?style=flat-square)](https://packagist.org/packages/spatie/url-signer)\n\nThis package can create URLs with a limited lifetime. This is done by adding an expiration date and a signature to the URL.\n\n```php\n$urlSigner = new Sha256UrlSigner('randomkey');\n\n$urlSigner-\u003esign('https://myapp.com', 30);\n\n// =\u003e The generated url will be valid for 30 seconds\n```\n\nThis will output a URL that looks like `https://myapp.com/?expires=xxxx\u0026signature=xxxx`.\n\nImagine mailing this URL out to the users of your application. When a user clicks on a signed URL\nyour application can validate it with:\n\n```php\n// returns `true` if valid, `false` if not\n$urlSigner-\u003evalidate('https://myapp.com/?expires=xxxx\u0026signature=xxxx');\n```\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/url-signer.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/url-signer)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Postcardware\n\nYou're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.\n\nOur address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.\n\nAll postcards are published [on our website](https://spatie.be/en/opensource/postcards).\n\n## Installation\n\nThe package can installed via Composer:\n```\ncomposer require spatie/url-signer\n```\n\n## Usage\n\nA signer-object can sign URLs and validate signed URLs. A secret key is used to generate signatures.\n\n```php\nuse Spatie\\UrlSigner\\Sha256UrlSigner;\n\n$urlSigner = new Sha256UrlSigner('mysecretkey');\n```\n\n### Generating URLs\n\nSigned URLs can be generated by providing a regular URL and an expiration date to the `sign` method.\n\n```php\n$expirationDate = (new DateTime())-\u003emodify('10 days');\n\n$urlSigner-\u003esign('https://myapp.com', $expirationDate);\n\n// =\u003e The generated url will be valid for 10 days\n```\n\nIf an integer is provided as expiration date, the URL will be valid for that amount of seconds.\n\n```php\n$urlSigner-\u003esign('https://myapp.com', 30);\n\n// =\u003e The generated URL will be valid for 30 seconds\n```\n\n### Validating URLs\n\nTo validate a signed URL, simply call the `validate()` method. This will return a boolean.\n\n```php\n$urlSigner-\u003evalidate('https://myapp.com/?expires=1439223344\u0026signature=a479abde194d111022a6831edbda29b14e7bdb760438a8a0be2556cd1a6c23fa');\n\n// =\u003e true\n\n$urlSigner-\u003evalidate('https://myapp.com/?expires=1439223344\u0026signature=a479abde194d111022a6831edbda-INVALID-29b14e7bdb760438a8a0be2556cd1a6c23fa');\n\n// =\u003e false\n```\n\n## Writing custom signers\n\nThis packages provides a signer that uses SHA256 to generate signature. You can create your own\nsigner by implementing the `Spatie\\UrlSigner\\Contracts\\UrlSigner`-interface. If you let your signer extend\n`Spatie\\UrlSigner\\AbstractUrlSigner` you'll only need to provide the `createSignature`-method.\n\n## Tests\n\nThe tests can be run with:\n\n```\ncomposer test\n```\n\n## Integrations\n\nTo get started quickly in Laravel you can use the [spatie/laravel-url-signer](https://github.com/spatie/laravel-url-signer) package.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [Sebastian De Deyne](https://github.com/sebastiandedeyne)\n- [All Contributors](../../contributors)\n\n## About Spatie\n\nSpatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Furl-signer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Furl-signer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Furl-signer/lists"}