Merge pull request #273 from versity/ben/auth

fix: cleanup auth.New for service selection
This commit is contained in:
Ben McClelland
2023-10-04 10:12:43 -07:00
committed by GitHub
2 changed files with 9 additions and 7 deletions
+9 -7
View File
@@ -50,13 +50,15 @@ type Opts struct {
}
func New(o *Opts) (IAMService, error) {
if o.Dir == "" {
if o.LDAPServerURL == "" {
return IAMServiceSingle{}, nil
} else {
return NewLDAPService(o.LDAPServerURL, o.LDAPBindDN, o.LDAPPassword, o.LDAPQueryBase, o.LDAPAccessAtr, o.LDAPSecretAtr, o.LDAPRoleAtr, o.LDAPObjClasses)
}
} else {
switch {
case o.Dir != "":
return NewInternal(o.Dir)
case o.LDAPServerURL != "":
return NewLDAPService(o.LDAPServerURL, o.LDAPBindDN, o.LDAPPassword,
o.LDAPQueryBase, o.LDAPAccessAtr, o.LDAPSecretAtr, o.LDAPRoleAtr,
o.LDAPObjClasses)
default:
// if no iam options selected, default to the single user mode
return IAMServiceSingle{}, nil
}
}