mirror of
https://github.com/gravitl/netmaker.git
synced 2026-04-23 00:17:10 +08:00
initialized
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gravitl/netmaker/config"
|
||||
)
|
||||
@@ -65,6 +66,12 @@ func GetServerConfig() config.ServerConfig {
|
||||
cfg.Database = GetDB()
|
||||
cfg.Platform = GetPlatform()
|
||||
cfg.Version = GetVersion()
|
||||
|
||||
// == auth config ==
|
||||
var authInfo = GetAuthProviderInfo()
|
||||
cfg.AuthProvider = authInfo[0]
|
||||
cfg.ClientID = authInfo[1]
|
||||
cfg.ClientSecret = authInfo[2]
|
||||
return cfg
|
||||
}
|
||||
func GetAPIConnString() string {
|
||||
@@ -398,6 +405,25 @@ func GetServerCheckinInterval() int64 {
|
||||
return t
|
||||
}
|
||||
|
||||
// GetAuthProviderInfo = gets the oauth provider info
|
||||
func GetAuthProviderInfo() []string {
|
||||
var authProvider = ""
|
||||
if os.Getenv("AUTH_PROVIDER") != "" && os.Getenv("CLIENT_ID") != "" && os.Getenv("CLIENT_SECRET") != "" {
|
||||
authProvider = strings.ToLower(os.Getenv("AUTH_PROVIDER"))
|
||||
if authProvider == "google" || authProvider == "azure-ad" || authProvider == "github" {
|
||||
return []string{authProvider, os.Getenv("CLIENT_ID"), os.Getenv("CLIENT_SECRET")}
|
||||
} else {
|
||||
authProvider = ""
|
||||
}
|
||||
} else if config.Config.Server.AuthProvider != "" && config.Config.Server.ClientID != "" && config.Config.Server.ClientSecret != "" {
|
||||
authProvider = strings.ToLower(config.Config.Server.AuthProvider)
|
||||
if authProvider == "google" || authProvider == "azure-ad" || authProvider == "github" {
|
||||
return []string{authProvider, config.Config.Server.ClientID, config.Config.Server.ClientSecret}
|
||||
}
|
||||
}
|
||||
return []string{"", "", ""}
|
||||
}
|
||||
|
||||
// GetMacAddr - get's mac address
|
||||
func getMacAddr() string {
|
||||
ifas, err := net.Interfaces()
|
||||
|
||||
Reference in New Issue
Block a user