storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/docs/sts/assume-role.md (about)

     1  # AssumeRole [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
     2  
     3  **Table of Contents**
     4  
     5  - [Introduction](#introduction)
     6  - [API Request Parameters](#api-request-parameters)
     7      - [Version](#version)
     8      - [AUTHPARAMS](#authparams)
     9      - [DurationSeconds](#durationseconds)
    10      - [Policy](#policy)
    11      - [Response Elements](#response-elements)
    12      - [Errors](#errors)
    13  - [Sample `POST` Request](#sample-post-request)
    14  - [Sample Response](#sample-response)
    15  - [Using AssumeRole API](#using-assumerole-api)
    16  - [Explore Further](#explore-further)
    17  
    18  <!-- markdown-toc end -->
    19  
    20  ## Introduction
    21  
    22  Returns a set of temporary security credentials that you can use to access MinIO resources. AssumeRole requires authorization credentials for an existing user on MinIO. The advantages of this API are
    23  
    24  - To be able to reliably use S3 multipart APIs feature of the SDKs without re-inventing the wheel of pre-signing the each URL in multipart API. This is very tedious to implement with all the scenarios of fault tolerance that's already implemented by the client SDK. The general client SDKs don't support multipart with presigned URLs.
    25  - To be able to easily get the temporary credentials to upload to a prefix. Make it possible for a client to upload a whole folder using the session. The server side applications need not create a presigned URL and serve to the client for each file. Since, the client would have the session it can do it by itself.
    26  
    27  The temporary security credentials returned by this API consists of an access key, a secret key, and a security token. Applications can use these temporary security credentials to sign calls to MinIO API operations. The policy applied to these temporary credentials is inherited from the MinIO user credentials. By default, the temporary security credentials created by AssumeRole last for one hour. However, use the optional DurationSeconds parameter to specify the duration of the credentials. This value varies from 900 seconds (15 minutes) up to the maximum session duration of 7 days.
    28  
    29  ## API Request Parameters
    30  ### Version
    31  Indicates STS API version information, the only supported value is '2011-06-15'. This value is borrowed from AWS STS API documentation for compatibility reasons.
    32  
    33  | Params     | Value    |
    34  | :--        | :--      |
    35  | *Type*     | *String* |
    36  | *Required* | *Yes*    |
    37  
    38  ### AUTHPARAMS
    39  Indicates STS API Authorization information. If you are familiar with AWS Signature V4 Authorization header, this STS API supports signature V4 authorization as mentioned [here](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html)
    40  
    41  ### DurationSeconds
    42  The duration, in seconds. The value can range from 900 seconds (15 minutes) up to 7 days. If value is higher than this setting, then operation fails. By default, the value is set to 3600 seconds.
    43  
    44  | Params        | Value                                            |
    45  | :--           | :--                                              |
    46  | *Type*        | *Integer*                                        |
    47  | *Valid Range* | *Minimum value of 900. Maximum value of 604800.* |
    48  | *Required*    | *No*                                             |
    49  
    50  ### Policy
    51  An IAM policy in JSON format that you want to use as an inline session policy. This parameter is optional. Passing policies to this operation returns new temporary credentials. The resulting session's permissions are the intersection of the canned policy name and the policy set here. You cannot use this policy to grant more permissions than those allowed by the canned policy name being assumed.
    52  
    53  | Params        | Value                                          |
    54  | :--           | :--                                            |
    55  | *Type*        | *String*                                       |
    56  | *Valid Range* | *Minimum length of 1. Maximum length of 2048.* |
    57  | *Required*    | *No*                                           |
    58  
    59  ### Response Elements
    60  XML response for this API is similar to [AWS STS AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_ResponseElements)
    61  
    62  ### Errors
    63  XML error response for this API is similar to [AWS STS AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_Errors)
    64  
    65  ## Sample `POST` Request
    66  ```
    67  http://minio:9000/?Action=AssumeRole&DurationSeconds=3600&Version=2011-06-15&Policy={"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"arn:aws:s3:::*"}]}&AUTHPARAMS
    68  ```
    69  
    70  ## Sample Response
    71  ```
    72  <?xml version="1.0" encoding="UTF-8"?>
    73  <AssumeRoleResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
    74    <AssumeRoleResult>
    75      <AssumedRoleUser>
    76        <Arn/>
    77        <AssumeRoleId/>
    78      </AssumedRoleUser>
    79      <Credentials>
    80        <AccessKeyId>Y4RJU1RNFGK48LGO9I2S</AccessKeyId>
    81        <SecretAccessKey>sYLRKS1Z7hSjluf6gEbb9066hnx315wHTiACPAjg</SecretAccessKey>
    82        <Expiration>2019-08-08T20:26:12Z</Expiration>
    83        <SessionToken>eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJZNFJKVTFSTkZHSzQ4TEdPOUkyUyIsImF1ZCI6IlBvRWdYUDZ1Vk80NUlzRU5SbmdEWGo1QXU1WWEiLCJhenAiOiJQb0VnWFA2dVZPNDVJc0VOUm5nRFhqNUF1NVlhIiwiZXhwIjoxNTQxODExMDcxLCJpYXQiOjE1NDE4MDc0NzEsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0Ojk0NDMvb2F1dGgyL3Rva2VuIiwianRpIjoiYTBiMjc2MjktZWUxYS00M2JmLTg3MzktZjMzNzRhNGNkYmMwIn0.ewHqKVFTaP-j_kgZrcOEKroNUjk10GEp8bqQjxBbYVovV0nHO985VnRESFbcT6XMDDKHZiWqN2vi_ETX_u3Q-w</SessionToken>
    84      </Credentials>
    85    </AssumeRoleResult>
    86    <ResponseMetadata>
    87      <RequestId>c6104cbe-af31-11e0-8154-cbc7ccf896c7</RequestId>
    88    </ResponseMetadata>
    89  </AssumeRoleResponse>
    90  ```
    91  
    92  ## Using AssumeRole API
    93  ```
    94  $ export MINIO_ROOT_USER=minio
    95  $ export MINIO_ROOT_PASSWORD=minio123
    96  $ minio server ~/test
    97  ```
    98  
    99  Create new users following the multi-user guide [here](https://docs.min.io/docs/minio-multi-user-quickstart-guide.html)
   100  
   101  Testing with an example
   102  > Use the same username and password created in the previous steps.
   103  
   104  ```
   105  [foobar]
   106  region = us-east-1
   107  aws_access_key_id = foobar
   108  aws_secret_access_key = foo12345
   109  ```
   110  
   111  > NOTE: In the following commands `--role-arn` and `--role-session-name` are not meaningful for MinIO and can be set to any value satisfying the command line requirements.
   112  
   113  ```
   114  $ aws --profile foobar --endpoint-url http://localhost:9000 sts assume-role --policy '{"Version":"2012-10-17","Statement":[{"Sid":"Stmt1","Effect":"Allow","Action":"s3:*","Resource":"arn:aws:s3:::*"}]}' --role-arn arn:xxx:xxx:xxx:xxxx --role-session-name anything
   115  {
   116      "AssumedRoleUser": {
   117          "Arn": ""
   118      },
   119      "Credentials": {
   120          "SecretAccessKey": "xbnWUoNKgFxi+uv3RI9UgqP3tULQMdI+Hj+4psd4",
   121          "SessionToken": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJLOURUSU1VVlpYRVhKTDNBVFVPWSIsImV4cCI6MzYwMDAwMDAwMDAwMCwicG9saWN5IjoidGVzdCJ9.PetK5wWUcnCJkMYv6TEs7HqlA4x_vViykQ8b2T_6hapFGJTO34sfTwqBnHF6lAiWxRoZXco11B0R7y58WAsrQw",
   122          "Expiration": "2019-02-20T19:56:59-08:00",
   123          "AccessKeyId": "K9DTIMUVZXEXJL3ATUOY"
   124      }
   125  }
   126  ```
   127  
   128  ## Explore Further
   129  - [MinIO Admin Complete Guide](https://docs.min.io/docs/minio-admin-complete-guide.html)
   130  - [The MinIO documentation website](https://docs.min.io)