netmaker/pro/controllers/middleware.go
Abhishek K c7e673fb9f
ACC-532: set mq clean session to true (#2865)
* set clean session

* delete emqx hosts creds api

* add emqx hosts del api to limited middleware controller

* add emqx hosts del api to limited middleware controller

* remove server creds from emqx
2024-03-20 15:03:41 +07:00

26 lines
708 B
Go

package controllers
import (
"net/http"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/servercfg"
)
var limitedApis = map[string]struct{}{
"/api/server/status": {},
"/api/emqx/hosts": {},
"/api/users/adm/authenticate": {},
}
func OnlyServerAPIWhenUnlicensedMiddleware(handler http.Handler) http.Handler {
return http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
if servercfg.ErrLicenseValidation != nil {
if _, ok := limitedApis[request.URL.Path]; !ok {
logic.ReturnErrorResponse(writer, request, logic.FormatError(servercfg.ErrLicenseValidation, "forbidden"))
return
}
}
handler.ServeHTTP(writer, request)
})
}