Loosen requirements to detach policies for LDAP (#18419)

This commit is contained in:
Taran Pelkey 2023-11-09 17:44:43 -05:00 committed by GitHub
parent 2229509362
commit 117ad1b65b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 9 deletions

View File

@ -1663,18 +1663,25 @@ func (sys *IAMSys) PolicyDBUpdateLDAP(ctx context.Context, isAttach bool,
return return
} }
if dn == "" { if dn == "" {
err = errNoSuchUser // Still attempt to detach if provided user is a DN.
return if !isAttach && sys.LDAPConfig.IsLDAPUserDN(r.User) {
dn = r.User
} else {
err = errNoSuchUser
return
}
} }
isGroup = false isGroup = false
} else { } else {
var exists bool if isAttach {
if exists, err = sys.LDAPConfig.DoesGroupDNExist(r.Group); err != nil { var exists bool
logger.LogIf(ctx, err) if exists, err = sys.LDAPConfig.DoesGroupDNExist(r.Group); err != nil {
return logger.LogIf(ctx, err)
} else if !exists { return
err = errNoSuchGroup } else if !exists {
return err = errNoSuchGroup
return
}
} }
dn = r.Group dn = r.Group
isGroup = true isGroup = true