{"id":16832476,"url":"https://github.com/kennethormandy/craft-s3securedownloads","last_synced_at":"2025-08-04T10:35:17.299Z","repository":{"id":37820199,"uuid":"225736688","full_name":"kennethormandy/craft-s3securedownloads","owner":"kennethormandy","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-16T22:21:12.000Z","size":234,"stargazers_count":4,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"5.x","last_synced_at":"2024-12-28T20:35:24.132Z","etag":null,"topics":["craft-plugin","craftcms-plugin"],"latest_commit_sha":null,"homepage":null,"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/kennethormandy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2019-12-03T23:25:34.000Z","updated_at":"2024-07-16T21:38:38.000Z","dependencies_parsed_at":"2024-07-17T01:45:20.601Z","dependency_job_id":"2ebdb883-e894-4a5d-98da-215283b2c55f","html_url":"https://github.com/kennethormandy/craft-s3securedownloads","commit_stats":{"total_commits":132,"total_committers":7,"mean_commits":"18.857142857142858","dds":"0.15909090909090906","last_synced_commit":"994c7effd4f0cafc452385bede3f1f3168eef5e4"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethormandy%2Fcraft-s3securedownloads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethormandy%2Fcraft-s3securedownloads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethormandy%2Fcraft-s3securedownloads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kennethormandy%2Fcraft-s3securedownloads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kennethormandy","download_url":"https://codeload.github.com/kennethormandy/craft-s3securedownloads/tar.gz/refs/heads/5.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231819015,"owners_count":18431234,"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":["craft-plugin","craftcms-plugin"],"created_at":"2024-10-13T11:49:13.360Z","updated_at":"2024-12-30T21:26:13.482Z","avatar_url":"https://github.com/kennethormandy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# S3 Secure Downloads plugin for Craft CMS\n\nThis plugin will return a [pre-signed URL](http://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURL.html) used to allow temporary access to private objects with an expiring URL. You can optionally allow file downloads only for logged in users and force file downloads (useful for PDF files).\n\nFrom the original developer, [Jonathan Melville](https://github.com/jonathanmelville/s3securedownloads):\n\n\u003e This plugin was originally developed for a client in the financial services industry who wanted to make sure only logged in users had access to downloads of financial reports, and download links couldn’t be shared. … Now you can keep your S3 objects private but grant temporary access to them with an expiring link. \n\n![Screenshot of the plugin settings.](./src/resources/screenshots/screenshot.png)\n\n## Installation\n\n```sh\n# Require the plugin with composer\ncomposer require kennethormandy/craft-s3securedownloads\n```\n\nThen, install the plugin:\n\n```sh\n# Install the plugin via the Control Panel, or by running:\n./craft plugin/install s3securedownloads\n```\n\n## Usage\n\nPass in an asset's entry id and it will return a pre-signed URL for that asset:\n\n```twig\n{% set asset = entry.myAssetField.one() %}\n\u003ca href=\"{{ getSignedUrl(asset.id) }}\"\u003e{{ asset }}\u003c/a\u003e\n```\n\nBy default, only users logged in will be able to generate the pre-signed URL. This can be changed within the plugin settings.\n\nThe generated a pre-signed AWS S3 URL will expire after 24 hours, or however long you have configured in the plugin settings.\n\n## Options\n\n### `filename`\n\nBy default, the download will use the same filename as the Craft CMS asset. Alternatively, a custom filename can be passed to AWS instead. For example:\n\n```twig\n{% set asset = entry.myAssetField.one() %}\n\u003ca href=\"{{ getSignedUrl(asset.id, { filename: 'my-new-filename.png' }) }}\"\u003e{{ asset }}\u003c/a\u003e\n```\n\n\u003c!--\n\n## AWS S3 configuration\n\n- Make sure you have configured the Craft AWS S3 plugin and setup an [AWS IAM permissions](https://github.com/craftcms/aws-s3#aws-iam-permissions)\n- Works with or without “Objects can be public” for S3 bucket public access permissions\n- Set “Assets in this volume have public URLs” to `true`, and give the bucket URL (although from more recent testing, you can set the bucket URL and then disable it, and the asset.url won’t be given? Maybe this is preferable in terms of config?)\n- Set “Make Uploads Public” to `false`\n\n- Optionally, configure the bucket to block certain signature versions https://docs.aws.amazon.com/AmazonS3/latest/API/bucket-policy-s3-sigv4-conditions.html\n\n--\u003e\n\n## Events\n\n- `kennethormandy\\s3securedownloads\\services\\SignUrl`\n  - `SignUrl::EVENT_BEFORE_SIGN_URL`\n  - `SignUrl::EVENT_AFTER_SIGN_URL`\n\n```php\nuse Craft;\nuse yii\\base\\Event;\nuse kennethormandy\\s3securedownloads\\events\\SignUrlEvent;\nuse kennethormandy\\s3securedownloads\\services\\SignUrl;\n\n// …\n\nEvent::on(\n    SignUrl::class,\n    SignUrl::EVENT_BEFORE_SIGN_URL,\n    function (SignUrlEvent $event) {\n        $asset = $event-\u003easset;\n        Craft::info(\"Handle EVENT_BEFORE_SIGN_URL event here\", __METHOD__);\n    }\n);\n\nEvent::on(\n    SignUrl::class,\n    SignUrl::EVENT_AFTER_SIGN_URL,\n    function (SignUrlEvent $event) {\n        $asset = $event-\u003easset;\n        Craft::info(\"Handle EVENT_AFTER_SIGN_URL event here\", __METHOD__);\n    }\n);\n```\n\n## Earlier versions\n\nS3 Secure Downloads is available for Craft 3, 4, and 5. For a version that runs on Craft v2.5.x, see [the original plugin](https://github.com/jonathanmelville/s3securedownloads). [Note that as of June 24, 2020](https://aws.amazon.com/blogs/aws/amazon-s3-update-sigv2-deprecation-period-extended-modified/) all new AWS S3 buckets require URLs to be signed using Signature Version 4, and the original plugin (understandably) only signs URLs using Signature Version 2.\n\n## License\n\n[The MIT License (MIT)](./LICENSE.md)\n\nCopyright © 2016–2019 [Jonathan Melville](https://github.com/jonathanmelville/s3securedownloads)\u003cbr/\u003e\nCopyright © 2019–2024 [Kenneth Ormandy Inc.](https://kennethormandy.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethormandy%2Fcraft-s3securedownloads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkennethormandy%2Fcraft-s3securedownloads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethormandy%2Fcraft-s3securedownloads/lists"}