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