mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
c7e673fb9f
* 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
26 lines
708 B
Go
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)
|
|
})
|
|
}
|