{"id":18273461,"url":"https://github.com/arraypress/hmac-signer","last_synced_at":"2025-08-21T14:11:55.646Z","repository":{"id":239479547,"uuid":"799646191","full_name":"arraypress/hmac-signer","owner":"arraypress","description":"Enables secure and verified access to resources by generating HMAC signed URLs, ideal for environments like CloudFlare R2 buckets.","archived":false,"fork":false,"pushed_at":"2024-05-18T20:27:42.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T03:41:25.819Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arraypress.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-05-12T18:50:57.000Z","updated_at":"2025-03-16T14:48:42.000Z","dependencies_parsed_at":"2024-05-12T19:45:59.599Z","dependency_job_id":"612345e2-8e57-41ce-9499-c56d14c04697","html_url":"https://github.com/arraypress/hmac-signer","commit_stats":null,"previous_names":["arraypress/hmac-signer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/arraypress/hmac-signer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fhmac-signer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fhmac-signer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fhmac-signer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fhmac-signer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arraypress","download_url":"https://codeload.github.com/arraypress/hmac-signer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fhmac-signer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271493232,"owners_count":24769117,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-05T12:06:33.356Z","updated_at":"2025-08-21T14:11:55.593Z","avatar_url":"https://github.com/arraypress.png","language":"PHP","readme":"# HMACSigner Library\n\nThe HMACSigner library simplifies the generation of HMAC signed URLs to secure access to resources stored in CloudFlare R2 buckets and other public storages. It is designed to integrate easily into PHP projects, enhancing security with timestamped and verifiable access links.\n\n## Minimum Requirements\n\n- PHP: 7.4 or higher\n\n## Installation\n\nHMAC Signer can be integrated directly into your PHP or WordPress projects. Here's how to get started:\n\n### Via Composer\n\n```bash\ncomposer require arraypress/hmac-signer\n```\n\n```php\n// Require the Composer autoloader to enable class autoloading.\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse function ArrayPress\\Utils\\HMACSigner\\get_attachment_signed;\nuse function ArrayPress\\Utils\\HMACSigner\\get_signed_resource;\n```\n\n## Usage Examples\n\n### Generating a Signed URL for a WordPress Attachment\n\n```php\n$signedUrl = get_attachment_signed( 123, 'https://previews.example.com', 'your-secret-key', 'audio-previews' );\necho \"Signed URL: \" . $signedUrl;\n```\n\n### Generating a Signed URL for a General Resource\n\n```php\n$signedUrl = get_signed_resource( 'my-song.mp3', 'https://previews.example.com', 'your-secret-key', 'audio-previews' );\necho \"Signed URL: \" . $signedUrl;\n```\n\n## CloudFlare WAF Configuration\n\nTo ensure the security of your resources with CloudFlare, configure a WAF rule to validate the HMAC signatures of your URLs:\n\n### Step 1: Access CloudFlare Dashboard\n\nLog in to your CloudFlare account and select the domain for which you want to configure the WAF rule.\n\n### Step 2: Navigate to the Firewall Section\n\nGo to the Firewall tab, then select Managed Rules.\n\n### Step 3: Create a Custom Firewall Rule\n\nClick on Create a Firewall rule and define the rule conditions and actions.\n\n### Step 4: Define the Rule Expression\n\n```bash\n(http.host eq \"previews.example.com\" and not is_timed_hmac_valid_v0(\"your-secret-key\", http.request.uri, 600, http.request.timestamp.sec, 8))\n```\n\nReplace \"your-secret-key\" with the secret key you use to generate your HMAC signatures.\n\n### Step 5: Set the Action\n\nChoose Block to prevent unauthorized access.\n\n### Step 6: Save and Deploy the Rule\n\nName your rule appropriately and click Deploy.\n\n## Testing Your Configuration\n\nEnsure your rule is effective by accessing a resource with both a valid and an invalid HMAC signature.\n\n## Contributions\n\nContributions to this library are highly appreciated. Raise issues on GitHub or submit pull requests for bug\nfixes or new features. Share feedback and suggestions for improvements.\n\n## License: GPLv2 or later\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public\nLicense as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later\nversion.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fhmac-signer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farraypress%2Fhmac-signer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fhmac-signer/lists"}