Skip to content

Commit

Permalink
Merge branch 'bugfix_v0.16.1_ee_checks' of https://github.com/gravitl…
Browse files Browse the repository at this point in the history
…/netmaker into feature_dyn_sec_latest
  • Loading branch information
abhishek9686 committed Sep 26, 2022
2 parents f632bec + 5f7d6ea commit faf7add
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
3 changes: 2 additions & 1 deletion controllers/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/servercfg"
)

// limit consts
Expand All @@ -22,7 +23,7 @@ func checkFreeTierLimits(limit_choice int, next http.Handler) http.HandlerFunc {
Code: http.StatusUnauthorized, Message: "free tier limits exceeded on networks",
}

if logic.Free_Tier && logic.Is_EE { // check that free tier limits not exceeded
if logic.Free_Tier && servercfg.Is_EE { // check that free tier limits not exceeded
if limit_choice == networks_l {
currentNetworks, err := logic.GetNetworks()
if (err != nil && !database.IsEmptyRecord(err)) || len(currentNetworks) >= logic.Networks_Limit {
Expand Down
32 changes: 16 additions & 16 deletions controllers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func allowUsers(next http.Handler) http.HandlerFunc {
//
// Get the server configuration.
//
// Schemes: https
// Schemes: https
//
// Security:
// oauth
// Security:
// oauth
//
// Responses:
// 200: serverConfigResponse
// Responses:
// 200: serverConfigResponse
func getServerInfo(w http.ResponseWriter, r *http.Request) {
// Set header
w.Header().Set("Content-Type", "application/json")
Expand All @@ -79,13 +79,13 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) {
//
// Get the server configuration.
//
// Schemes: https
// Schemes: https
//
// Security:
// oauth
// Security:
// oauth
//
// Responses:
// 200: serverConfigResponse
// Responses:
// 200: serverConfigResponse
func getConfig(w http.ResponseWriter, r *http.Request) {
// Set header
w.Header().Set("Content-Type", "application/json")
Expand All @@ -94,7 +94,7 @@ func getConfig(w http.ResponseWriter, r *http.Request) {

scfg := servercfg.GetServerConfig()
scfg.IsEE = "no"
if logic.Is_EE {
if servercfg.Is_EE {
scfg.IsEE = "yes"
}
json.NewEncoder(w).Encode(scfg)
Expand All @@ -105,13 +105,13 @@ func getConfig(w http.ResponseWriter, r *http.Request) {
//
// Registers a client with the server and return the Certificate Authority and certificate.
//
// Schemes: https
// Schemes: https
//
// Security:
// oauth
// Security:
// oauth
//
// Responses:
// 200: registerResponse
// Responses:
// 200: registerResponse
func register(w http.ResponseWriter, r *http.Request) {
logger.Log(2, "processing registration request")
w.Header().Set("Content-Type", "application/json")
Expand Down
3 changes: 2 additions & 1 deletion logic/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/gravitl/netmaker/logic/pro"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/models/promodels"
"github.com/gravitl/netmaker/servercfg"
"golang.org/x/crypto/bcrypt"
)

Expand Down Expand Up @@ -140,7 +141,7 @@ func CreateUser(user models.User) (models.User, error) {

// legacy
if StringSliceContains(user.Networks, currentNets[i].NetID) {
if !Is_EE {
if !servercfg.Is_EE {
newUser.AccessLevel = pro.NET_ADMIN
}
}
Expand Down
2 changes: 1 addition & 1 deletion mq/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func UpdateNode(client mqtt.Client, msg mqtt.Message) {

// UpdateMetrics message Handler -- handles updates from client nodes for metrics
func UpdateMetrics(client mqtt.Client, msg mqtt.Message) {
if logic.Is_EE {
if servercfg.Is_EE {
go func() {
id, err := getID(msg.Topic())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion mq/publishers.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func ServerStartNotify() error {

// function to collect and store metrics for server nodes
func collectServerMetrics(networks []models.Network) {
if !logic.Is_EE {
if !servercfg.Is_EE {
return
}
if len(networks) > 0 {
Expand Down

0 comments on commit faf7add

Please sign in to comment.