Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pkg/credentials/sts_ldap_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ type LDAPIdentity struct {

// Optional, used for token revokation
TokenRevokeType string

// Optional, the LDAP configuration name to use for the LDAP identity
// provider.
LDAPTargetName string
}

// NewLDAPIdentity returns new credentials object that uses LDAP
Expand Down Expand Up @@ -110,6 +114,22 @@ func LDAPIdentityExpiryOpt(d time.Duration) LDAPIdentityOpt {
}
}

// LDAPIdentityTokenRevokeTypeOpt sets the token revokation type for requested
// credentials.
func LDAPIdentityTokenRevokeTypeOpt(tokenRevokeType string) LDAPIdentityOpt {
return func(k *LDAPIdentity) {
k.TokenRevokeType = tokenRevokeType
}
}

// LDAPIdentityTargetNameOpt sets the LDAP configuration name for requested
// credentials.
func LDAPIdentityTargetNameOpt(targetName string) LDAPIdentityOpt {
return func(k *LDAPIdentity) {
k.LDAPTargetName = targetName
}
}

// NewLDAPIdentityWithSessionPolicy returns new credentials object that uses
// LDAP Identity with a specified session policy. The `policy` parameter must be
// a JSON string specifying the policy document.
Expand Down Expand Up @@ -158,6 +178,9 @@ func (k *LDAPIdentity) RetrieveWithCredContext(cc *CredContext) (value Value, er
if k.TokenRevokeType != "" {
v.Set("TokenRevokeType", k.TokenRevokeType)
}
if k.LDAPTargetName != "" {
v.Set("LDAPTargetName", k.LDAPTargetName)
}

req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(v.Encode()))
if err != nil {
Expand Down
Loading