github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/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  
     3  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.
     4  
     5  ## Get started
     6  
     7  In this document we will explain in detail on how to configure multiple users.
     8  
     9  ### 1. Prerequisites
    10  
    11  - Install mc - [MinIO Client Quickstart Guide](https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart)
    12  - Install MinIO - [MinIO Quickstart Guide](https://min.io/docs/minio/linux/index.html#quickstart-for-linux)
    13  - Configure etcd - [Etcd V3 Quickstart Guide](https://github.com/minio/minio/blob/master/docs/sts/etcd.md)
    14  
    15  ### 2. Create a new user with canned policy
    16  
    17  Use [`mc admin policy`](https://min.io/docs/minio/linux/reference/minio-mc-admin/mc-admin-policy.html) 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.
    18  
    19  Create new canned policy file `getonly.json`. This policy enables users to download all objects under `my-bucketname`.
    20  
    21  ```json
    22  cat > getonly.json << EOF
    23  {
    24    "Version": "2012-10-17",
    25    "Statement": [
    26  	{
    27  	  "Action": [
    28  		"s3:GetObject"
    29  	  ],
    30  	  "Effect": "Allow",
    31  	  "Resource": [
    32  		"arn:aws:s3:::my-bucketname/*"
    33  	  ],
    34  	  "Sid": ""
    35  	}
    36    ]
    37  }
    38  EOF
    39  ```
    40  
    41  Create new canned policy by name `getonly` using `getonly.json` policy file.
    42  
    43  ```
    44  mc admin policy create myminio getonly getonly.json
    45  ```
    46  
    47  Create a new user `newuser` on MinIO use `mc admin user`.
    48  
    49  ```
    50  mc admin user add myminio newuser newuser123
    51  ```
    52  
    53  Once the user is successfully created you can now apply the `getonly` policy for this user.
    54  
    55  ```
    56  mc admin policy attach myminio getonly --user=newuser
    57  ```
    58  
    59  ### 3. Create a new group
    60  
    61  ```
    62  mc admin group add myminio newgroup newuser
    63  ```
    64  
    65  Once the group is successfully created you can now apply the `getonly` policy for this group.
    66  
    67  ```
    68  mc admin policy attach myminio getonly --group=newgroup
    69  ```
    70  
    71  ### 4. Disable user
    72  
    73  Disable user `newuser`.
    74  
    75  ```
    76  mc admin user disable myminio newuser
    77  ```
    78  
    79  Disable group `newgroup`.
    80  
    81  ```
    82  mc admin group disable myminio newgroup
    83  ```
    84  
    85  ### 5. Remove user
    86  
    87  Remove the user `newuser`.
    88  
    89  ```
    90  mc admin user remove myminio newuser
    91  ```
    92  
    93  Remove the user `newuser` from a group.
    94  
    95  ```
    96  mc admin group remove myminio newgroup newuser
    97  ```
    98  
    99  Remove the group `newgroup`.
   100  
   101  ```
   102  mc admin group remove myminio newgroup
   103  ```
   104  
   105  ### 6. Change user or group policy
   106  
   107  Change the policy for user `newuser` to `putonly` canned policy.
   108  
   109  ```
   110  mc admin policy attach myminio putonly --user=newuser
   111  ```
   112  
   113  Change the policy for group `newgroup` to `putonly` canned policy.
   114  
   115  ```
   116  mc admin policy attach myminio putonly --group=newgroup
   117  ```
   118  
   119  ### 7. List all users or groups
   120  
   121  List all enabled and disabled users.
   122  
   123  ```
   124  mc admin user list myminio
   125  ```
   126  
   127  List all enabled or disabled groups.
   128  
   129  ```
   130  mc admin group list myminio
   131  ```
   132  
   133  ### 8. Configure `mc`
   134  
   135  ```
   136  mc alias set myminio-newuser http://localhost:9000 newuser newuser123 --api s3v4
   137  mc cat myminio-newuser/my-bucketname/my-objectname
   138  ```
   139  
   140  ### Policy Variables
   141  
   142  You can use policy variables in the *Resource* element and in string comparisons in the *Condition* element.
   143  
   144  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.
   145  
   146  ```
   147  {
   148    "Version": "2012-10-17",
   149    "Statement": [
   150  	{
   151  	  "Action": ["s3:ListBucket"],
   152  	  "Effect": "Allow",
   153  	  "Resource": ["arn:aws:s3:::mybucket"],
   154  	  "Condition": {"StringLike": {"s3:prefix": ["${aws:username}/*"]}}
   155  	},
   156  	{
   157  	  "Action": [
   158  		"s3:GetObject",
   159  		"s3:PutObject"
   160  	  ],
   161  	  "Effect": "Allow",
   162  	  "Resource": ["arn:aws:s3:::mybucket/${aws:username}/*"]
   163  	}
   164    ]
   165  }
   166  ```
   167  
   168  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. List of policy variables for OpenID based STS.
   169  
   170  - `jwt:sub`
   171  - `jwt:iss`
   172  - `jwt:aud`
   173  - `jwt:jti`
   174  - `jwt:upn`
   175  - `jwt:name`
   176  - `jwt:groups`
   177  - `jwt:given_name`
   178  - `jwt:family_name`
   179  - `jwt:middle_name`
   180  - `jwt:nickname`
   181  - `jwt:preferred_username`
   182  - `jwt:profile`
   183  - `jwt:picture`
   184  - `jwt:website`
   185  - `jwt:email`
   186  - `jwt:gender`
   187  - `jwt:birthdate`
   188  - `jwt:phone_number`
   189  - `jwt:address`
   190  - `jwt:scope`
   191  - `jwt:client_id`
   192  
   193  Following example shows OpenID users with full programmatic access to a OpenID user-specific directory (their own "home directory") in MinIO.
   194  
   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": ["${jwt:preferred_username}/*"]}}
   204  	},
   205  	{
   206  	  "Action": [
   207  		"s3:GetObject",
   208  		"s3:PutObject"
   209  	  ],
   210  	  "Effect": "Allow",
   211  	  "Resource": ["arn:aws:s3:::mybucket/${jwt:preferred_username}/*"]
   212  	}
   213    ]
   214  }
   215  ```
   216  
   217  If the user is authenticating using an STS credential which was authorized from AD/LDAP we allow `ldap:*` variables.
   218  
   219  Currently supports
   220  
   221  - `ldap:username`
   222  - `ldap:user`
   223  - `ldap:groups`
   224  
   225  Following example shows LDAP users full programmatic access to a LDAP user-specific directory (their own "home directory") in MinIO.
   226  
   227  ```
   228  {
   229    "Version": "2012-10-17",
   230    "Statement": [
   231  	{
   232  	  "Action": ["s3:ListBucket"],
   233  	  "Effect": "Allow",
   234  	  "Resource": ["arn:aws:s3:::mybucket"],
   235  	  "Condition": {"StringLike": {"s3:prefix": ["${ldap:username}/*"]}}
   236  	},
   237  	{
   238  	  "Action": [
   239  		"s3:GetObject",
   240  		"s3:PutObject"
   241  	  ],
   242  	  "Effect": "Allow",
   243  	  "Resource": ["arn:aws:s3:::mybucket/${ldap:username}/*"]
   244  	}
   245    ]
   246  }
   247  ```
   248  
   249  #### Common information available in all requests
   250  
   251  - `aws:CurrentTime` - This can be used for conditions that check the date and time.
   252  - `aws:EpochTime` - This is the date in epoch or Unix time, for use with date/time conditions.
   253  - `aws:PrincipalType` - This value indicates whether the principal is an account (Root credential), user (MinIO user), or assumed role (STS)
   254  - `aws:SecureTransport` - This is a Boolean value that represents whether the request was sent over TLS.
   255  - `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.
   256  
   257  ```
   258  {
   259    "Version": "2012-10-17",
   260    "Statement": {
   261  	"Effect": "Allow",
   262  	"Action": "s3:ListBucket*",
   263  	"Resource": "arn:aws:s3:::mybucket",
   264  	"Condition": {"IpAddress": {"aws:SourceIp": "203.0.113.0/24"}}
   265    }
   266  }
   267  ```
   268  
   269  - `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.
   270  - `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, use `jwt:preferred_username` in case of OpenID connect and `ldap:username` in case of AD/LDAP. *aws:userid* is an alias to *aws:username* in MinIO.
   271  - `aws:groups` - This is an array containing the group names, this value would point to group mappings for the user, use `jwt:groups` in case of OpenID connect and `ldap:groups` in case of AD/LDAP.
   272  
   273  ## Explore Further
   274  
   275  - [MinIO Client Complete Guide](https://min.io/docs/minio/linux/reference/minio-mc.html)
   276  - [MinIO STS Quickstart Guide](https://min.io/docs/minio/linux/developers/security-token-service.html)
   277  - [MinIO Admin Complete Guide](https://min.io/docs/minio/linux/reference/minio-mc-admin.html)
   278  - [The MinIO documentation website](https://min.io/docs/minio/linux/index.html)