From 6f1629b2bd420cd748c339ff5cfb21fcf4751756 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Wed, 4 Oct 2023 08:53:30 -0700 Subject: [PATCH] fix: cleanup auth.New for service selection --- auth/iam.go | 16 +++++++++------- auth/{iam-ldap.go => iam_ldap.go} | 0 2 files changed, 9 insertions(+), 7 deletions(-) rename auth/{iam-ldap.go => iam_ldap.go} (100%) diff --git a/auth/iam.go b/auth/iam.go index 47bc3fcd..c7952ef2 100644 --- a/auth/iam.go +++ b/auth/iam.go @@ -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 } } diff --git a/auth/iam-ldap.go b/auth/iam_ldap.go similarity index 100% rename from auth/iam-ldap.go rename to auth/iam_ldap.go