epiphanyinfotech/laravel-aws-custom-policy-url-signer
Composer 安装命令:
composer require epiphanyinfotech/laravel-aws-custom-policy-url-signer
包简介
Get epiphanyinfotech custom policy url to append to cloudfront file with a valid key-pair id and time limit
README 文档
README
Easy to use Laravel 6+ | 7+ | 8+ wrapper which allows to sign URLs to access Private Content through CloudFront CDN
This package can create custom policy signed URLs for CloudFront which expires after a given time. The default time is set to 86400 seconds or 24 hours. This package does not depends on AWS SDK package, but implements the example from (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CreateURL_PHP.html#sample-custom-policy)
The benefit of this approach is that you can use the same signature for multiple files and hence the processing is much much faster when you are loading multiple signed images/videos or other files on a single page.
This is how you can create signed URL that's valid for 1 day or 24 hour:
Usage
Signing URLs
// Add Namespace in Controller use EpiphanyInfotech\CustomPolicyUrl\CustomPolicyUrl as AWSURL; /* * Instantiate the class and pass the array with values matching * the path of the media files in the AWS S3 Bubket */ $key_id = config('aws-custom-policy-url.KEY-ID'); $aws_private_key = config('aws-custom-policy-url.AWS-PRIVATE-KEY'); $path_arr = array('sample_5mb.mp4','sample_3mb.mp4'); // get the sample files either from your own DB or changing the storage config to s3 bucket and fetching the list of files. Ref.: (https://laravel.com/docs/8.x/filesystem#retrieving-files) $aws_obj = New AWSURL($key_id, $aws_private_key); $get_signed_urls = $aws_obj->getSignedUrls($path_arr);
The output is compliant with CloudFront specifications
Installation
The package can be installed via Composer:
composer require epiphanyinfotech/laravel-aws-custom-policy-url-signer:^1.0
Configuration
The configuration file can optionally be published via:
php artisan vendor:publish --provider="EpiphanyInfotech\CustomPolicyUrl\CustomPolicyUrlServiceProvider"
This is the content of the file:
return [ /* * The cloudfront public keys id. Identifies the CloudFront key pair associated to the trusted signer which validates signed URLs. * To create a key, refer: https://console.aws.amazon.com/cloudfront/v3/home?region=us-east-2#/publickey * Make sure to replace region=us-east-2 with your region */ 'KEY-ID' => env("AWS_KEY_ID", NULL), /* * The private key used to sign all URLs. Make sure it's secured and not accessible to public. Enter absolute path in the .env file */ "AWS-PRIVATE-KEY" => env("AWS_PRIVATE_KEY_FILEPATH", NULL), /* * The IP address of the client making the GET request. For further info, visit: (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-custom-policy.html) and search for - "IpAddress (Optional)" */ "CLIENT_IP" => env("AWS_CLIENT_IP", NULL),, /* * Your CloudFront domain URL. To check your cloudfront domain, visit: (https://console.aws.amazon.com/cloudfront/v3/home?region=us-east-2#/distributions) * Make sure to replace region=us-east-2 with your region. * The "Domain Name" is your URL. If you have configured cloudfront to use the custom domain, then enter that. */ "AWS_URL" => env("AWS_URL", NULL), ];
Security
If you discover any security related issues, please email info@epiphanyinfotech.com or use the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
epiphanyinfotech/laravel-aws-custom-policy-url-signer 适用场景与选型建议
epiphanyinfotech/laravel-aws-custom-policy-url-signer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 07 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「custom-policy-signed-url」 「epiphanyinfotech」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 epiphanyinfotech/laravel-aws-custom-policy-url-signer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 epiphanyinfotech/laravel-aws-custom-policy-url-signer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-26