diff --git a/internal/model/config.go b/internal/model/config.go index 0bd4f3b5..975d7e94 100644 --- a/internal/model/config.go +++ b/internal/model/config.go @@ -178,15 +178,16 @@ type UIConfig struct { } type LDAPConfig struct { - Address string `description:"LDAP server address." yaml:"address"` - BindDN string `description:"Bind DN for LDAP authentication." yaml:"bindDn"` - BindPassword string `description:"Bind password for LDAP authentication." yaml:"bindPassword"` - BaseDN string `description:"Base DN for LDAP searches." yaml:"baseDn"` - Insecure bool `description:"Allow insecure LDAP connections." yaml:"insecure"` - SearchFilter string `description:"LDAP search filter." yaml:"searchFilter"` - AuthCert string `description:"Certificate for mTLS authentication." yaml:"authCert"` - AuthKey string `description:"Certificate key for mTLS authentication." yaml:"authKey"` - GroupCacheTTL int `description:"Cache duration for LDAP group membership in seconds." yaml:"groupCacheTTL"` + Address string `description:"LDAP server address." yaml:"address"` + BindDN string `description:"Bind DN for LDAP authentication." yaml:"bindDn"` + BindPassword string `description:"Bind password for LDAP authentication." yaml:"bindPassword"` + BindPasswordFile string `description:"Path to the Bind password." yaml:"bindPasswordFile"` + BaseDN string `description:"Base DN for LDAP searches." yaml:"baseDn"` + Insecure bool `description:"Allow insecure LDAP connections." yaml:"insecure"` + SearchFilter string `description:"LDAP search filter." yaml:"searchFilter"` + AuthCert string `description:"Certificate for mTLS authentication." yaml:"authCert"` + AuthKey string `description:"Certificate key for mTLS authentication." yaml:"authKey"` + GroupCacheTTL int `description:"Cache duration for LDAP group membership in seconds." yaml:"groupCacheTTL"` } type LogConfig struct { diff --git a/internal/service/ldap_service.go b/internal/service/ldap_service.go index cb0f0f5a..819cb9d3 100644 --- a/internal/service/ldap_service.go +++ b/internal/service/ldap_service.go @@ -11,6 +11,7 @@ import ( ldapgo "github.com/go-ldap/ldap/v3" "github.com/steveiliop56/ding" "github.com/tinyauthapp/tinyauth/internal/model" + "github.com/tinyauthapp/tinyauth/internal/utils" "github.com/tinyauthapp/tinyauth/internal/utils/logger" ) @@ -32,6 +33,10 @@ func NewLdapService( return nil, nil } + secret := utils.GetSecret(config.LDAP.BindPassword, config.LDAP.BindPasswordFile) + config.LDAP.BindPassword = secret + config.LDAP.BindPasswordFile = "" + ldap := &LdapService{ log: log, config: config,