reallyli / laravel-aliyun-sts
Laravel 的阿里云 STS。
1.0.0
2020-11-05 10:28 UTC
Requires
- php: >=7.0
- ext-json: *
- alibabacloud/sts: ^1.8
- aliyuncs/oss-sdk-php: ^2.4
- illuminate/support: ~5.0||~6.0||~7.0||^8.0
This package is auto-updated.
Last update: 2024-09-05 18:49:08 UTC
README
🎃 Laravel 的阿里云 STS。
安装
$ composer require reallyli/laravel-aliyun-sts -v
在更新 composer 后,如果你使用的是 laravel 版本 < 5.5,你需要注册服务提供者
// config/app.php 'providers' => [ //... Reallyli\AliyunSts\ServiceProvider::class, ],
并发布配置文件
$ php artisan vendor:publish --provider=Reallyli\\AliyunSts\\ServiceProvider
如果你想使用外观模式,你可以注册你想要使用的名称,例如 AliyunSts
// config/app.php 'aliases' => [ 'AliyunSts' => Reallyli\AliyunSts\AliyunSts::class, // This is default in laravel 5.5 ],
配置
// config/sts.php return [ /** * @link https://help.aliyun.com/document_detail/100624.html * AccessKeyId、AccessKeySecret:子账号AK信息 */ 'accessKeyId' => env('ALIYUN_STS_ACCESS_KEY_ID'), 'accessKeySecret' => env('ALIYUN_STS_ACCESS_KEY_SECRET'), /** * @link https://help.aliyun.com/document_detail/66053.html * regionId和endpoint */ 'regionId' => env('ALIYUN_STS_REGION_ID'), 'endpoint' => env('ALIYUN_STS_ENDPOINT'), /** * @link https://help.aliyun.com/document_detail/100624.html * 创建角色(需要扮演的角色ID) */ 'roleArn' => env('ALIYUN_STS_ROLE_ARN'), /** * @link https://help.aliyun.com/document_detail/100624.html * 设置临时凭证的有效期,单位是s,最小为900,最大为3600 */ 'expiration' => env('ALIYUN_STS_EXIRATION'), // 令牌过期时间 /** * @link https://help.aliyun.com/document_detail/100624.html * RoleSessionName即临时身份的会话名称,用于区分不同的临时身份 */ 'clientName' => env('ALIYUN_STS_CLIENT_NAME'), /** * @link https://help.aliyun.com/document_detail/100624.html * 创建权限策略(在扮演角色的时候额外添加的权限限制) */ 'policy' => [ 'Statement' => [ [ 'Action' => "*", 'Effect' => 'Allow', 'Resource' => [ "acs:oss:*:*:default", ], ], ], "Version" => "1", ], ];
用法
AliyunSts::getCredentials();