reallyli/laravel-aliyun-sts

Aliyun STS for Laravel.
1,461 2
Install
composer require reallyli/laravel-aliyun-sts
Latest Version:1.0.0
PHP:>=7.0
License:MIT
Last Updated:Nov 5, 2020
Links: GitHub  ·  Packagist
Maintainer: reallyli

Laravel Aliyun STS

:jack_o_lantern: Aliyun STS for Laravel.

Installing

$ composer require reallyli/laravel-aliyun-sts -v

After updated composer, if you are using laravel version < 5.5, you need to register service provider:

// config/app.php

'providers' => [
    //...
    Reallyli\AliyunSts\ServiceProvider::class,
],

And publish the config file:

$ php artisan vendor:publish --provider=Reallyli\\AliyunSts\\ServiceProvider

if you want to use facade mode, you can register a facade name what you want to use, for example AliyunSts:

// config/app.php

'aliases' => [
    'AliyunSts' => Reallyli\AliyunSts\AliyunSts::class, // This is default in laravel 5.5
],

configuration

// 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",
    ],
];

Usage

AliyunSts::getCredentials();

Links

Contact

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
1.0.0 >=7.0 ~5.0||~6.0||~7.0||^8.0 MIT