diff --git a/cmd/gonic/gonic.go b/cmd/gonic/gonic.go index 3235e1d..81f9e22 100644 --- a/cmd/gonic/gonic.go +++ b/cmd/gonic/gonic.go @@ -47,6 +47,7 @@ import ( "go.senan.xyz/gonic/tags/tagcommon" "go.senan.xyz/gonic/tags/taglib" "go.senan.xyz/gonic/transcode" + "go.senan.xyz/gonic/ldap" ) func main() { @@ -82,6 +83,22 @@ func main() { confExcludePattern := flag.String("exclude-pattern", "", "regex pattern to exclude files from scan (optional)") + var ldapConfig ldap.Config + flag.StringVar(&ldapConfig.BindUser, "ldap-bind-user", "", "the bind user to bind to LDAP with (required for LDAP)") + flag.StringVar(&ldapConfig.BindPass, "ldap-bind-pass", "", "the password of the LDAP bind user (required for LDAP)") + flag.StringVar(&ldapConfig.BaseDN, "ldap-base-dn", "", "the base DN for LDAP objects (required for LDAP)") + flag.StringVar(&ldapConfig.Filter, "ldap-filter", "(uid=*)", "the filter to select LDAP objects with (optional)") + + flag.StringVar(&ldapConfig.FQDN, "ldap-fqdn", "", "the name of the server to connect to (required for LDAP)") + flag.UintVar(&ldapConfig.Port, "ldap-port", 389, "what port the LDAP server is hosted on (optional)") + flag.BoolVar(&ldapConfig.TLS, "ldap-tls", false, "whether gonic will connect to the LDAP server using TLS (optional)") + + if ldapConfig.FQDN != "" { + if ldapConfig.BindUser == "" || ldapConfig.BindPass == "" || ldapConfig.BaseDN == "" { + log.Fatal("a server was provided for an LDAP connection, but configuration is incomplete") + } + } + var confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for mutli-valued genre scanning (optional)") flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for mutli-valued track artist scanning (optional)") diff --git a/gonic.db.1711991474.bak b/gonic.db.1711991474.bak new file mode 100644 index 0000000..5fbd153 Binary files /dev/null and b/gonic.db.1711991474.bak differ diff --git a/ldap/ldap.go b/ldap/ldap.go index 24e84da..1ac657d 100644 --- a/ldap/ldap.go +++ b/ldap/ldap.go @@ -10,6 +10,17 @@ import ( "github.com/go-ldap/ldap/v3" ) +type Config struct { + BindUser string + BindPass string + BaseDN string + Filter string + + FQDN string + Port uint + TLS bool +} + func CheckLDAPcreds(username string, password string, dbc *db.DB) (bool, error) { ldapFQDN, err := dbc.GetSetting("ldap_fqdn")