add tls support
This commit is contained in:
parent
043fa955ec
commit
9939859c0d
@ -18,6 +18,8 @@ type Config struct {
|
||||
Ldap *LdapConfig
|
||||
Secret string
|
||||
Tls bool
|
||||
Key string
|
||||
Cert string
|
||||
Port string
|
||||
}
|
||||
|
||||
@ -41,6 +43,8 @@ func LoadConfig() (*Config, error) {
|
||||
c := &Config{}
|
||||
l := &LdapConfig{}
|
||||
viper.SetDefault("port", "8080")
|
||||
viper.SetDefault("secret", "")
|
||||
viper.SetDefault("Tls", false)
|
||||
//Load configs
|
||||
l.Url = viper.GetString("ldapUrl")
|
||||
l.AdminUser = viper.GetString("adminUser")
|
||||
@ -50,6 +54,8 @@ func LoadConfig() (*Config, error) {
|
||||
c.Secret = viper.GetString("secret")
|
||||
c.Tls = viper.GetBool("tls")
|
||||
c.Port = viper.GetString("port")
|
||||
c.Key = viper.GetString("tls_key")
|
||||
c.Cert = viper.GetString("tls_cert")
|
||||
|
||||
//Validate configs
|
||||
if validateConfigEntry(l.Url, "ldapUrl") || validateConfigEntry(l.AdminUser, "adminUser") || validateConfigEntry(l.UserOu, "userOu") || validateConfigEntry(l.LdapDc, "ldapDc") || validateConfigEntry(l.UserAttr, "userAttr") {
|
||||
|
7
main.go
7
main.go
@ -45,6 +45,9 @@ func main() {
|
||||
http.HandleFunc("/register", signupPage)
|
||||
http.HandleFunc("/", homePage)
|
||||
log.Printf("Guildgate starting on %v\n", Conf.Port)
|
||||
http.ListenAndServe(":"+Conf.Port, nil)
|
||||
|
||||
if Conf.Tls {
|
||||
http.ListenAndServeTLS(":"+Conf.Port, Conf.Cert, Conf.Key, nil)
|
||||
} else {
|
||||
http.ListenAndServe(":"+Conf.Port, nil)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user