Skip to content

Commit

Permalink
go mod tidy and conver azure tenant to env/conf var
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdcarns committed Jan 3, 2022
1 parent d45d417 commit 76a75fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions auth/azure-ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os"

"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
Expand Down Expand Up @@ -36,7 +35,7 @@ func initAzureAD(redirectURL string, clientID string, clientSecret string) {
ClientID: clientID,
ClientSecret: clientSecret,
Scopes: []string{"User.Read"},
Endpoint: microsoft.AzureADEndpoint(os.Getenv("AZURE_TENANT")),
Endpoint: microsoft.AzureADEndpoint(servercfg.GetAzureTenant()),
}
}

Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type ServerConfig struct {
ClientSecret string `yaml:"clientsecret"`
FrontendURL string `yaml:"frontendurl"`
DisplayKeys string `yaml:"displaykeys"`
AzureTenant string `yaml:"azuretenant"`
}

// Generic SQL Config
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require (
require (
cloud.google.com/go v0.34.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
Expand Down
11 changes: 11 additions & 0 deletions servercfg/serverconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,17 @@ func GetAuthProviderInfo() []string {
return []string{"", "", ""}
}

// GetAzureTenant - retrieve the azure tenant ID from env variable or config file
func GetAzureTenant() string {
var azureTenant = ""
if os.Getenv("AZURE_TENANT") != "" {
azureTenant = os.Getenv("AZURE_TENANT")
} else if config.Config.Server.AzureTenant != "" {
azureTenant = config.Config.Server.AzureTenant
}
return azureTenant
}

// GetMacAddr - get's mac address
func getMacAddr() string {
ifas, err := net.Interfaces()
Expand Down

0 comments on commit 76a75fb

Please sign in to comment.