github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/docs/sts/ldap.md (about)

     1  # AssumeRoleWithLDAPIdentity [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
     2  
     3  ## Introduction
     4  
     5  MinIO provides a custom STS API that allows integration with LDAP based corporate environments including Microsoft Active Directory. The MinIO server uses a separate LDAP service account to lookup user information. The login flow for a user is as follows:
     6  
     7  - User provides their AD/LDAP username and password to the STS API.
     8  - MinIO looks up the user's information (specifically the user's Distinguished Name) in the LDAP server.
     9  - On finding the user's info, MinIO verifies the login credentials with the AD/LDAP server.
    10  - MinIO optionally queries the AD/LDAP server for a list of groups that the user is a member of.
    11  - MinIO then checks if there are any policies [explicitly associated](#managing-usergroup-access-policy) with the user or their groups.
    12  - On finding at least one associated policy, MinIO generates temporary credentials for the user storing the list of groups in a cryptographically secure session token. The temporary access key, secret key and session token are returned to the user.
    13  - The user can now use these credentials to make requests to the MinIO server.
    14  
    15  The administrator will associate IAM access policies with each group and if required with the user too. The MinIO server then evaluates applicable policies on a user (these are the policies associated with the groups along with the policy on the user if any) to check if the request should be allowed or denied.
    16  
    17  To ensure that changes in the LDAP directory are reflected in object storage access changes, MinIO performs an **Automatic LDAP sync**. MinIO periodically queries the LDAP service to:
    18  
    19  - find accounts (user DNs) that have been removed; any active STS credentials or MinIO service accounts belonging to these users are purged.
    20  
    21  - find accounts whose group memberships have changed; access policies available to a credential are updated to reflect the change, i.e. they will lose any privileges associated with a group they are removed from, and gain any privileges associated with a group they are added to.
    22  
    23  **Please note that when AD/LDAP is configured, MinIO will not support long term users defined internally.** Only AD/LDAP users (and the root user) are allowed. In addition to this, the server will not support operations on users or groups using `mc admin user` or `mc admin group` commands except `mc admin user info` and `mc admin group info` to list set policies for users and groups. This is because users and groups are defined externally in AD/LDAP.
    24  
    25  ## Configuring AD/LDAP on MinIO
    26  
    27  LDAP STS configuration can be performed via MinIO's standard configuration API (i.e. using `mc admin config set/get` commands) or equivalently via environment variables. For brevity we refer to environment variables here.
    28  
    29  LDAP is configured via the following environment variables:
    30  
    31  ```
    32  $ mc admin config set myminio identity_ldap --env
    33  KEY:
    34  identity_ldap  enable LDAP SSO support
    35  
    36  ARGS:
    37  MINIO_IDENTITY_LDAP_SERVER_ADDR*             (address)   AD/LDAP server address e.g. "myldap.com" or "myldapserver.com:1686"
    38  MINIO_IDENTITY_LDAP_SRV_RECORD_NAME          (string)    DNS SRV record name for LDAP service, if given, must be one of ldap, ldaps or on
    39  MINIO_IDENTITY_LDAP_LOOKUP_BIND_DN*          (string)    DN for LDAP read-only service account used to perform DN and group lookups
    40  MINIO_IDENTITY_LDAP_LOOKUP_BIND_PASSWORD     (string)    Password for LDAP read-only service account used to perform DN and group lookups
    41  MINIO_IDENTITY_LDAP_USER_DN_SEARCH_BASE_DN*  (list)      ";" separated list of user search base DNs e.g. "dc=myldapserver,dc=com"
    42  MINIO_IDENTITY_LDAP_USER_DN_SEARCH_FILTER*   (string)    Search filter to lookup user DN
    43  MINIO_IDENTITY_LDAP_GROUP_SEARCH_FILTER      (string)    search filter for groups e.g. "(&(objectclass=groupOfNames)(memberUid=%s))"
    44  MINIO_IDENTITY_LDAP_GROUP_SEARCH_BASE_DN     (list)      ";" separated list of group search base DNs e.g. "dc=myldapserver,dc=com"
    45  MINIO_IDENTITY_LDAP_TLS_SKIP_VERIFY          (on|off)    trust server TLS without verification, defaults to "off" (verify)
    46  MINIO_IDENTITY_LDAP_SERVER_INSECURE          (on|off)    allow plain text connection to AD/LDAP server, defaults to "off"
    47  MINIO_IDENTITY_LDAP_SERVER_STARTTLS          (on|off)    use StartTLS connection to AD/LDAP server, defaults to "off"
    48  MINIO_IDENTITY_LDAP_COMMENT                  (sentence)  optionally add a comment to this setting
    49  ```
    50  
    51  ### LDAP server connectivity
    52  
    53  The variables relevant to configuring connectivity to the LDAP service are:
    54  
    55  ```
    56  MINIO_IDENTITY_LDAP_SERVER_ADDR*             (address)   AD/LDAP server address e.g. "myldap.com" or "myldapserver.com:1686"
    57  MINIO_IDENTITY_LDAP_SRV_RECORD_NAME          (string)    DNS SRV record name for LDAP service, if given, must be one of ldap, ldaps or on
    58  MINIO_IDENTITY_LDAP_TLS_SKIP_VERIFY         (on|off)    trust server TLS without verification, defaults to "off" (verify)
    59  MINIO_IDENTITY_LDAP_SERVER_INSECURE         (on|off)    allow plain text connection to AD/LDAP server, defaults to "off"
    60  MINIO_IDENTITY_LDAP_SERVER_STARTTLS         (on|off)    use StartTLS connection to AD/LDAP server, defaults to "off"
    61  ```
    62  
    63  The server address variable is _required_. TLS is assumed to be on by default. The port in the server address is optional and defaults to 636 if not provided.
    64  
    65  **MinIO sends LDAP credentials to the LDAP server for validation. So we _strongly recommend_ to use MinIO with AD/LDAP server over TLS or StartTLS _only_. Using plain-text connection between MinIO and LDAP server means _credentials can be compromised_ by anyone listening to network traffic.**
    66  
    67  If a self-signed certificate is being used, the certificate can be added to MinIO's certificates directory, so it can be trusted by the server.
    68  
    69  #### DNS SRV Records
    70  
    71  Many Active Directory and other LDAP services are setup with [DNS SRV Records](https://ldap.com/dns-srv-records-for-ldap/) for high-availability of the directory service. To use this to find LDAP servers to connect to, an LDAP client makes a DNS SRV record request to the DNS service on a domain that looks like `_service._proto.example.com`. For LDAP the `proto` value is always `tcp`, and `service` is usually `ldap` or `ldaps`.
    72  
    73  To enable MinIO to use the SRV records, specify the `srv_record_name` config parameter (or equivalently the `MINIO_IDENTITY_LDAP_SRV_RECORD_NAME` environment variable). This parameter can be set to `ldap` or `ldaps` and MinIO will substitute it into the `service` value. For example, when `server_addr=myldapserver.com` and `srv_record_name=ldap`, MinIO will lookup the SRV record for `_ldap._tcp.myldapserver.com` and pick an appropriate target for LDAP requests.
    74  
    75  If the DNS SRV record is at an entirely different place, say `_ldapsrv._tcpish.myldapserver.com`, then set `srv_record_name` to the special value `on` and set `server_addr=_ldapsrv._tcpish.myldapserver.com`.
    76  
    77  When using this feature, do not specify a port in the `server_addr` as the port is picked up automatically from the SRV record.
    78  
    79  With the default (empty) value for `srv_record_name`, MinIO **will not** perform any SRV record request.
    80  
    81  The value of `srv_record_name` does not affect any TLS settings - they must be configured with their own parameters.
    82  
    83  ### Lookup-Bind
    84  
    85  A low-privilege read-only LDAP service account is configured in the MinIO server by providing the account's Distinguished Name (DN) and password. This service account is used to perform directory lookups as needed.
    86  
    87  ```
    88  MINIO_IDENTITY_LDAP_LOOKUP_BIND_DN*          (string)    DN for LDAP read-only service account used to perform DN and group lookups
    89  MINIO_IDENTITY_LDAP_LOOKUP_BIND_PASSWORD     (string)    Password for LDAP read-only service account used to perform DN and group lookups
    90  ```
    91  
    92  If you set an empty lookup bind password, the lookup bind will use the unauthenticated authentication mechanism, as described in [RFC 4513 Section 5.1.2](https://tools.ietf.org/html/rfc4513#section-5.1.2).
    93  
    94  ### User lookup
    95  
    96  When a user provides their LDAP credentials, MinIO runs a lookup query to find the user's Distinguished Name (DN). The search filter and base DN used in this lookup query are configured via the following variables:
    97  
    98  ```
    99  MINIO_IDENTITY_LDAP_USER_DN_SEARCH_BASE_DN*  (list)      ";" separated list of user search base DNs e.g. "dc=myldapserver,dc=com"
   100  MINIO_IDENTITY_LDAP_USER_DN_SEARCH_FILTER*   (string)    Search filter to lookup user DN
   101  ```
   102  
   103  The search filter must use the LDAP username to find the user DN. This is done via [variable substitution](#variable-substitution-in-configuration-strings).
   104  
   105  The returned user's DN and their password are then verified with the LDAP server. The user DN may also be associated with an [access policy](#managing-usergroup-access-policy).
   106  
   107  
   108  ### Group membership search
   109  
   110  MinIO can be optionally configured to find the groups of a user from AD/LDAP by specifying the following variables:
   111  
   112  ```
   113  MINIO_IDENTITY_LDAP_GROUP_SEARCH_FILTER     (string)    search filter for groups e.g. "(&(objectclass=groupOfNames)(memberUid=%s))"
   114  MINIO_IDENTITY_LDAP_GROUP_SEARCH_BASE_DN    (list)      ";" separated list of group search base DNs e.g. "dc=myldapserver,dc=com"
   115  ```
   116  
   117  The search filter must use the username or the DN to find the user's groups. This is done via [variable substitution](#variable-substitution-in-configuration-strings).
   118  
   119  A group's DN may be associated with an [access policy](#managing-usergroup-access-policy).
   120  
   121  #### Nested groups usage in LDAP/AD
   122  If you are using Active directory with nested groups you have to add LDAP_MATCHING_RULE_IN_CHAIN: :1.2.840.113556.1.4.1941: to your query.
   123  For example:
   124  ```shell
   125  group_search_filter: (&(objectClass=group)(member:1.2.840.113556.1.4.1941:=%d))
   126  user_dn_search_filter: (&(memberOf:1.2.840.113556.1.4.1941:=CN=group,DC=dc,DC=net)(sAMAccountName=%s))
   127  ```
   128  
   129  ### Sample settings
   130  
   131  Here are some (minimal) sample settings for development or experimentation:
   132  
   133  ```shell
   134  export MINIO_IDENTITY_LDAP_SERVER_ADDR=myldapserver.com:636
   135  export MINIO_IDENTITY_LDAP_LOOKUP_BIND_DN='cn=admin,dc=min,dc=io'
   136  export MINIO_IDENTITY_LDAP_LOOKUP_BIND_PASSWORD=admin
   137  export MINIO_IDENTITY_LDAP_USER_DN_SEARCH_BASE_DN='ou=hwengg,dc=min,dc=io'
   138  export MINIO_IDENTITY_LDAP_USER_DN_SEARCH_FILTER='(uid=%s)'
   139  export MINIO_IDENTITY_LDAP_TLS_SKIP_VERIFY=on
   140  ```
   141  
   142  ### Variable substitution in configuration strings
   143  
   144  In the configuration variables, `%s` is substituted with the _username_ from the STS request and `%d` is substituted with the _distinguished username (user DN)_ of the LDAP user. Please see the following table for which configuration variables support these substitution variables:
   145  
   146  | Variable                                    | Supported substitutions |
   147  |---------------------------------------------|-------------------------|
   148  | `MINIO_IDENTITY_LDAP_USER_DN_SEARCH_FILTER` | `%s`                    |
   149  | `MINIO_IDENTITY_LDAP_GROUP_SEARCH_FILTER`   | `%s` and `%d`           |
   150  
   151  ## Managing User/Group Access Policy
   152  
   153  Access policies may be associated by their name with a group or user directly. Access policies are first defined on the MinIO server using IAM policy JSON syntax. To define a new policy, you can use the [AWS policy generator](https://awspolicygen.s3.amazonaws.com/policygen.html). Copy the policy into a text file `mypolicy.json` and issue the command like so:
   154  
   155  ```sh
   156  mc admin policy create myminio mypolicy mypolicy.json
   157  ```
   158  
   159  To associate the policy with an LDAP user or group, use the full DN of the user or group:
   160  
   161  ```sh
   162  mc idp ldap policy attach myminio mypolicy --user='uid=james,cn=accounts,dc=myldapserver,dc=com'
   163  ```
   164  
   165  ```sh
   166  mc idp ldap policy attach myminio mypolicy ----group='cn=projectx,ou=groups,ou=hwengg,dc=min,dc=io'
   167  ```
   168  
   169  To remove a policy association, use the similar `detach` command:
   170  
   171  ```sh
   172  mc idp ldap policy detach myminio mypolicy --user='uid=james,cn=accounts,dc=myldapserver,dc=com'
   173  ```
   174  
   175  ```sh
   176  mc idp ldap policy detach myminio mypolicy ----group='cn=projectx,ou=groups,ou=hwengg,dc=min,dc=io'
   177  ```
   178  
   179  
   180  Note that the commands above attempt to validate if the given entity (user or group) exist in the LDAP directory and return an error if they are not found.
   181  
   182  <details><summary> View **DEPRECATED** older policy association commands</summary>
   183  
   184  Please **do not use** these as they may be removed or their behavior may change.
   185  
   186  ```sh
   187  mc admin policy attach myminio mypolicy --user='uid=james,cn=accounts,dc=myldapserver,dc=com'
   188  ```
   189  
   190  
   191  ```sh
   192  mc admin policy attach myminio mypolicy --group='cn=projectx,ou=groups,ou=hwengg,dc=min,dc=io'
   193  ```
   194  
   195  </details>
   196  
   197  **Note that by default no policy is set on a user**. Thus even if they successfully authenticate with AD/LDAP credentials, they have no access to object storage as the default access policy is to deny all access.
   198  
   199  ## API Request Parameters
   200  
   201  ### LDAPUsername
   202  
   203  Is AD/LDAP username to login. Application must ask user for this value to successfully obtain rotating access credentials from AssumeRoleWithLDAPIdentity.
   204  
   205  | Params               | Value                                          |
   206  | :--                  | :--                                            |
   207  | _Type_               | _String_                                       |
   208  | _Length Constraints_ | _Minimum length of 2. Maximum length of 2048._ |
   209  | _Required_           | _Yes_                                          |
   210  
   211  ### LDAPPassword
   212  
   213  Is AD/LDAP username password to login. Application must ask user for this value to successfully obtain rotating access credentials from AssumeRoleWithLDAPIdentity.
   214  
   215  | Params               | Value                                          |
   216  | :--                  | :--                                            |
   217  | _Type_               | _String_                                       |
   218  | _Length Constraints_ | _Minimum length of 4. Maximum length of 2048._ |
   219  | _Required_           | _Yes_                                          |
   220  
   221  ### Version
   222  
   223  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.
   224  
   225  | Params     | Value    |
   226  | :--        | :--      |
   227  | _Type_     | _String_ |
   228  | _Required_ | _Yes_    |
   229  
   230  ### DurationSeconds
   231  
   232  The duration, in seconds. The value can range from 900 seconds (15 minutes) up to 365 days. If value is higher than this setting, then operation fails. By default, the value is set to 3600 seconds.
   233  
   234  | Params        | Value                                              |
   235  | :--           | :--                                                |
   236  | _Type_        | _Integer_                                          |
   237  | _Valid Range_ | _Minimum value of 900. Maximum value of 31536000._ |
   238  | _Required_    | _No_                                               |
   239  
   240  ### Policy
   241  
   242  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.
   243  
   244  | Params        | Value                                          |
   245  | :--           | :--                                            |
   246  | _Type_        | _String_                                       |
   247  | _Valid Range_ | _Minimum length of 1. Maximum length of 2048._ |
   248  | _Required_    | _No_                                           |
   249  
   250  ### Response Elements
   251  
   252  XML response for this API is similar to [AWS STS AssumeRoleWithWebIdentity](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html#API_AssumeRoleWithWebIdentity_ResponseElements)
   253  
   254  ### Errors
   255  
   256  XML error response for this API is similar to [AWS STS AssumeRoleWithWebIdentity](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html#API_AssumeRoleWithWebIdentity_Errors)
   257  
   258  ## Sample `POST` Request
   259  
   260  ```
   261  http://minio.cluster:9000?Action=AssumeRoleWithLDAPIdentity&LDAPUsername=foouser&LDAPPassword=foouserpassword&Version=2011-06-15&DurationSeconds=7200
   262  ```
   263  
   264  ## Sample Response
   265  
   266  ```
   267  <?xml version="1.0" encoding="UTF-8"?>
   268  <AssumeRoleWithLDAPIdentityResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
   269    <AssumeRoleWithLDAPIdentityResult>
   270      <AssumedRoleUser>
   271        <Arn/>
   272        <AssumeRoleId/>
   273      </AssumedRoleUser>
   274      <Credentials>
   275        <AccessKeyId>Y4RJU1RNFGK48LGO9I2S</AccessKeyId>
   276        <SecretAccessKey>sYLRKS1Z7hSjluf6gEbb9066hnx315wHTiACPAjg</SecretAccessKey>
   277        <Expiration>2019-08-08T20:26:12Z</Expiration>
   278        <SessionToken>eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJZNFJKVTFSTkZHSzQ4TEdPOUkyUyIsImF1ZCI6IlBvRWdYUDZ1Vk80NUlzRU5SbmdEWGo1QXU1WWEiLCJhenAiOiJQb0VnWFA2dVZPNDVJc0VOUm5nRFhqNUF1NVlhIiwiZXhwIjoxNTQxODExMDcxLCJpYXQiOjE1NDE4MDc0NzEsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0Ojk0NDMvb2F1dGgyL3Rva2VuIiwianRpIjoiYTBiMjc2MjktZWUxYS00M2JmLTg3MzktZjMzNzRhNGNkYmMwIn0.ewHqKVFTaP-j_kgZrcOEKroNUjk10GEp8bqQjxBbYVovV0nHO985VnRESFbcT6XMDDKHZiWqN2vi_ETX_u3Q-w</SessionToken>
   279      </Credentials>
   280    </AssumeRoleWithLDAPIdentity>
   281    <ResponseMetadata/>
   282  </AssumeRoleWithLDAPIdentityResponse>
   283  ```
   284  
   285  ## Using LDAP STS API
   286  
   287  With multiple OU hierarchies for users, and multiple group search base DN's.
   288  
   289  ```
   290  export MINIO_ROOT_USER=minio
   291  export MINIO_ROOT_PASSWORD=minio123
   292  export MINIO_IDENTITY_LDAP_SERVER_ADDR='my.ldap-active-dir-server.com:636'
   293  export MINIO_IDENTITY_LDAP_LOOKUP_BIND_DN='cn=admin,dc=min,dc=io'
   294  export MINIO_IDENTITY_LDAP_LOOKUP_BIND_PASSWORD=admin
   295  export MINIO_IDENTITY_LDAP_GROUP_SEARCH_BASE_DN='dc=minioad,dc=local;dc=somedomain,dc=com'
   296  export MINIO_IDENTITY_LDAP_GROUP_SEARCH_FILTER='(&(objectclass=groupOfNames)(member=%d))'
   297  minio server ~/test
   298  ```
   299  
   300  You can make sure it works appropriately using our [example program](https://raw.githubusercontent.com/minio/minio/master/docs/sts/ldap.go):
   301  
   302  ```
   303  $ go run ldap.go -u foouser -p foopassword
   304  
   305  ##### Credentials
   306  {
   307          "accessKey": "NUIBORZYTV2HG2BMRSXR",
   308          "secretKey": "qQlP5O7CFPc5m5IXf1vYhuVTFj7BRVJqh0FqZ86S",
   309          "expiration": "2018-08-21T17:10:29-07:00",
   310          "sessionToken": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJOVUlCT1JaWVRWMkhHMkJNUlNYUiIsImF1ZCI6IlBvRWdYUDZ1Vk80NUlzRU5SbmdEWGo1QXU1WWEiLCJhenAiOiJQb0VnWFA2dVZPNDVJc0VOUm5nRFhqNUF1NVlhIiwiZXhwIjoxNTM0ODk2NjI5LCJpYXQiOjE1MzQ4OTMwMjksImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0Ojk0NDMvb2F1dGgyL3Rva2VuIiwianRpIjoiNjY2OTZjZTctN2U1Ny00ZjU5LWI0MWQtM2E1YTMzZGZiNjA4In0.eJONnVaSVHypiXKEARSMnSKgr-2mlC2Sr4fEGJitLcJF_at3LeNdTHv0_oHsv6ZZA3zueVGgFlVXMlREgr9LXA"
   311  }
   312  ```
   313  
   314  ## Explore Further
   315  
   316  - [MinIO Admin Complete Guide](https://min.io/docs/minio/linux/reference/minio-mc-admin.html)
   317  - [The MinIO documentation website](https://min.io/docs/minio/linux/index.html)