Skip to content

Commit dd17dfb

Browse files
support optional parameters in LdapIdentityProvider (#1528) (#1541)
Signed-off-by: Jeeva Kandasamy <[email protected]> Signed-off-by: Bala.FA <[email protected]> Co-authored-by: Jeeva Kandasamy <[email protected]>
1 parent 4170c34 commit dd17dfb

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

minio/credentials/providers.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -541,21 +541,30 @@ def retrieve(self) -> Credentials:
541541
class LdapIdentityProvider(Provider):
542542
"""Credential provider using AssumeRoleWithLDAPIdentity API."""
543543

544-
def __init__(
544+
def __init__( # pylint: disable=too-many-positional-arguments
545545
self,
546546
sts_endpoint: str,
547547
ldap_username: str,
548548
ldap_password: str,
549+
duration_seconds: Optional[int] = None,
550+
policy: Optional[str] = None,
551+
token_revoke_type: Optional[str] = None,
549552
http_client: Optional[PoolManager] = None,
550553
):
551-
self._sts_endpoint = sts_endpoint + "?" + urlencode(
552-
{
553-
"Action": "AssumeRoleWithLDAPIdentity",
554-
"Version": "2011-06-15",
555-
"LDAPUsername": ldap_username,
556-
"LDAPPassword": ldap_password,
557-
},
558-
)
554+
query_params = {
555+
"Action": "AssumeRoleWithLDAPIdentity",
556+
"Version": "2011-06-15",
557+
"LDAPUsername": ldap_username,
558+
"LDAPPassword": ldap_password,
559+
}
560+
if duration_seconds:
561+
query_params["DurationSeconds"] = str(duration_seconds)
562+
if policy:
563+
query_params["Policy"] = policy
564+
if token_revoke_type:
565+
query_params["TokenRevokeType"] = token_revoke_type
566+
567+
self._sts_endpoint = sts_endpoint + "?" + urlencode(query_params)
559568
self._http_client = http_client or PoolManager(
560569
retries=Retry(
561570
total=5,

0 commit comments

Comments
 (0)