storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/docs/multi-user/README.md (about)

     1  # MinIO Multi-user Quickstart Guide [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
     2  MinIO supports multiple long term users in addition to default user created during server startup. New users can be added after server starts up, and server can be configured to deny or allow access to buckets and resources to each of these users. This document explains how to add/remove users and modify their access rights.
     3  
     4  ## Get started
     5  In this document we will explain in detail on how to configure multiple users.
     6  
     7  ### 1. Prerequisites
     8  - Install mc - [MinIO Client Quickstart Guide](https://docs.min.io/docs/minio-client-quickstart-guide.html)
     9  - Install MinIO - [MinIO Quickstart Guide](https://docs.min.io/docs/minio-quickstart-guide)
    10  - Configure etcd (optional needed only in gateway or federation mode) - [Etcd V3 Quickstart Guide](https://github.com/minio/minio/blob/master/docs/sts/etcd.md)
    11  
    12  ### 2. Create a new user with canned policy
    13  Use [`mc admin policy`](https://docs.min.io/docs/minio-admin-complete-guide.html#policies) to create canned policies. Server provides a default set of canned policies namely `writeonly`, `readonly` and `readwrite` *(these policies apply to all resources on the server)*. These can be overridden by custom policies using `mc admin policy` command.
    14  
    15  Create new canned policy file `getonly.json`. This policy enables users to download all objects under `my-bucketname`.
    16  ```json
    17  cat > getonly.json << EOF
    18  {
    19    "Version": "2012-10-17",
    20    "Statement": [
    21      {
    22        "Action": [
    23          "s3:GetObject"
    24        ],
    25        "Effect": "Allow",
    26        "Resource": [
    27          "arn:aws:s3:::my-bucketname/*"
    28        ],
    29        "Sid": ""
    30      }
    31    ]
    32  }
    33  EOF
    34  ```
    35  
    36  Create new canned policy by name `getonly` using `getonly.json` policy file.
    37  ```
    38  mc admin policy add myminio getonly getonly.json
    39  ```
    40  
    41  Create a new user `newuser` on MinIO use `mc admin user`.
    42  ```
    43  mc admin user add myminio newuser newuser123
    44  ```
    45  
    46  Once the user is successfully created you can now apply the `getonly` policy for this user.
    47  ```
    48  mc admin policy set myminio getonly user=newuser
    49  ```
    50  
    51  ### 3. Create a new group
    52  ```
    53  mc admin group add myminio newgroup newuser
    54  ```
    55  
    56  Once the group is successfully created you can now apply the `getonly` policy for this group.
    57  ```
    58  mc admin policy set myminio getonly group=newgroup
    59  ```
    60  
    61  ### 4. Disable user
    62  Disable user `newuser`.
    63  ```
    64  mc admin user disable myminio newuser
    65  ```
    66  
    67  Disable group `newgroup`.
    68  ```
    69  mc admin group disable myminio newgroup
    70  ```
    71  
    72  ### 5. Remove user
    73  Remove the user `newuser`.
    74  ```
    75  mc admin user remove myminio newuser
    76  ```
    77  
    78  Remove the user `newuser` from a group.
    79  ```
    80  mc admin group remove myminio newgroup newuser
    81  ```
    82  
    83  Remove the group `newgroup`.
    84  ```
    85  mc admin group remove myminio newgroup
    86  ```
    87  
    88  ### 6. Change user or group policy
    89  Change the policy for user `newuser` to `putonly` canned policy.
    90  ```
    91  mc admin policy set myminio putonly user=newuser
    92  ```
    93  
    94  Change the policy for group `newgroup` to `putonly` canned policy.
    95  ```
    96  mc admin policy set myminio putonly group=newgroup
    97  ```
    98  
    99  ### 7. List all users or groups
   100  List all enabled and disabled users.
   101  ```
   102  mc admin user list myminio
   103  ```
   104  
   105  List all enabled or disabled groups.
   106  ```
   107  mc admin group list myminio
   108  ```
   109  
   110  ### 8. Configure `mc`
   111  ```
   112  mc alias set myminio-newuser http://localhost:9000 newuser newuser123 --api s3v4
   113  mc cat myminio-newuser/my-bucketname/my-objectname
   114  ```
   115  
   116  ### Policy Variables
   117  You can use policy variables in the *Resource* element and in string comparisons in the *Condition* element.
   118  
   119  You can use a policy variable in the Resource element, but only in the resource portion of the ARN. This portion of the ARN appears after the 5th colon (:). You can't use a variable to replace parts of the ARN before the 5th colon, such as the service or account. The following policy might be attached to a group. It gives each of the users in the group full programmatic access to a user-specific object (their own "home directory") in MinIO.
   120  
   121  ```
   122  {
   123    "Version": "2012-10-17",
   124    "Statement": [
   125      {
   126        "Action": ["s3:ListBucket"],
   127        "Effect": "Allow",
   128        "Resource": ["arn:aws:s3:::mybucket"],
   129        "Condition": {"StringLike": {"s3:prefix": ["${aws:username}/*"]}}
   130      },
   131      {
   132        "Action": [
   133          "s3:GetObject",
   134          "s3:PutObject"
   135        ],
   136        "Effect": "Allow",
   137        "Resource": ["arn:aws:s3:::mybucket/${aws:username}/*"]
   138      }
   139    ]
   140  }
   141  ```
   142  
   143  If the user is authenticating using an STS credential which was authorized from OpenID connect we allow all `jwt:*` variables specified in the JWT specification, custom `jwt:*` or extensions are not supported.
   144  
   145  List of policy variables for OpenID based STS.
   146  ```
   147  "jwt:sub"
   148  "jwt:iss"
   149  "jwt:aud"
   150  "jwt:jti"
   151  "jwt:upn"
   152  "jwt:name"
   153  "jwt:groups"
   154  "jwt:given_name"
   155  "jwt:family_name"
   156  "jwt:middle_name"
   157  "jwt:nickname"
   158  "jwt:preferred_username"
   159  "jwt:profile"
   160  "jwt:picture"
   161  "jwt:website"
   162  "jwt:email"
   163  "jwt:gender"
   164  "jwt:birthdate"
   165  "jwt:phone_number"
   166  "jwt:address"
   167  "jwt:scope"
   168  "jwt:client_id"
   169  ```
   170  
   171  Following example shows OpenID users with full programmatic access to a OpenID user-specific directory (their own "home directory") in MinIO.
   172  ```
   173  {
   174    "Version": "2012-10-17",
   175    "Statement": [
   176      {
   177        "Action": ["s3:ListBucket"],
   178        "Effect": "Allow",
   179        "Resource": ["arn:aws:s3:::mybucket"],
   180        "Condition": {"StringLike": {"s3:prefix": ["${jwt:preferred_username}/*"]}}
   181      },
   182      {
   183        "Action": [
   184          "s3:GetObject",
   185          "s3:PutObject"
   186        ],
   187        "Effect": "Allow",
   188        "Resource": ["arn:aws:s3:::mybucket/${jwt:preferred_username}/*"]
   189      }
   190    ]
   191  }
   192  ```
   193  
   194  If the user is authenticating using an STS credential which was authorized from AD/LDAP we allow `ldap:*` variables, currently only supports `ldap:user`. Following example shows LDAP users full programmatic access to a LDAP user-specific directory (their own "home directory") in MinIO.
   195  ```
   196  {
   197    "Version": "2012-10-17",
   198    "Statement": [
   199      {
   200        "Action": ["s3:ListBucket"],
   201        "Effect": "Allow",
   202        "Resource": ["arn:aws:s3:::mybucket"],
   203        "Condition": {"StringLike": {"s3:prefix": ["${ldap:user}/*"]}}
   204      },
   205      {
   206        "Action": [
   207          "s3:GetObject",
   208          "s3:PutObject"
   209        ],
   210        "Effect": "Allow",
   211        "Resource": ["arn:aws:s3:::mybucket/${ldap:user}/*"]
   212      }
   213    ]
   214  }
   215  ```
   216  
   217  #### Common information available in all requests
   218  
   219  - *aws:CurrentTime* - This can be used for conditions that check the date and time.
   220  - *aws:EpochTime* - This is the date in epoch or Unix time, for use with date/time conditions.
   221  - *aws:PrincipalType* - This value indicates whether the principal is an account (Root credential), user (MinIO user), or assumed role (STS)
   222  - *aws:SecureTransport* - This is a Boolean value that represents whether the request was sent over TLS.
   223  - *aws:SourceIp* - This is the requester's IP address, for use with IP address conditions. If running behind Nginx like proxies, MinIO preserve's the source IP.
   224  
   225  ```
   226  {
   227    "Version": "2012-10-17",
   228    "Statement": {
   229      "Effect": "Allow",
   230      "Action": "s3:ListBucket*",
   231      "Resource": "arn:aws:s3:::mybucket",
   232      "Condition": {"IpAddress": {"aws:SourceIp": "203.0.113.0/24"}}
   233    }
   234  }
   235  ```
   236  
   237  - *aws:UserAgent* - This value is a string that contains information about the requester's client application. This string is generated by the client and can be unreliable. You can only use this context key from `mc` or other MinIO SDKs which standardize the User-Agent string.
   238  - *aws:username* - This is a string containing the friendly name of the current user, this value would point to STS temporary credential in `AssumeRole`ed requests, instead use `jwt:preferred_username` in case of OpenID connect and `ldap:user` in case of AD/LDAP connect. *aws:userid* is an alias to *aws:username* in MinIO.
   239  
   240  
   241  ## Explore Further
   242  - [MinIO Client Complete Guide](https://docs.min.io/docs/minio-client-complete-guide)
   243  - [MinIO STS Quickstart Guide](https://docs.min.io/docs/minio-sts-quickstart-guide)
   244  - [MinIO Admin Complete Guide](https://docs.min.io/docs/minio-admin-complete-guide.html)
   245  - [The MinIO documentation website](https://docs.min.io)