2019-10-24 14:38:09 -04:00
|
|
|
// +build !consulent
|
|
|
|
|
2017-11-28 16:06:26 -08:00
|
|
|
package agent
|
|
|
|
|
2019-10-24 14:38:09 -04:00
|
|
|
import (
|
2019-12-06 11:14:56 -05:00
|
|
|
"fmt"
|
2019-10-24 14:38:09 -04:00
|
|
|
"net/http"
|
2019-12-06 11:14:56 -05:00
|
|
|
"strings"
|
2019-10-24 14:38:09 -04:00
|
|
|
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
)
|
2018-02-17 17:31:24 -08:00
|
|
|
|
2019-12-06 11:14:56 -05:00
|
|
|
func (s *HTTPServer) parseEntMeta(req *http.Request, entMeta *structs.EnterpriseMeta) error {
|
|
|
|
if headerNS := req.Header.Get("X-Consul-Namespace"); headerNS != "" {
|
|
|
|
return BadRequestError{Reason: "Invalid header: \"X-Consul-Namespace\" - Namespaces is a Consul Enterprise feature"}
|
|
|
|
}
|
|
|
|
if queryNS := req.URL.Query().Get("ns"); queryNS != "" {
|
|
|
|
return BadRequestError{Reason: "Invalid query parameter: \"ns\" - Namespaces is a Consul Enterprise feature"}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:01:34 -05:00
|
|
|
func (s *HTTPServer) parseEntMetaNoWildcard(req *http.Request, _ *structs.EnterpriseMeta) error {
|
|
|
|
return s.parseEntMeta(req, nil)
|
|
|
|
}
|
|
|
|
|
2019-12-06 11:14:56 -05:00
|
|
|
func (s *HTTPServer) rewordUnknownEnterpriseFieldError(err error) error {
|
|
|
|
if err == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
msg := err.Error()
|
|
|
|
|
|
|
|
if strings.Contains(msg, "json: unknown field ") {
|
|
|
|
quotedField := strings.TrimPrefix(msg, "json: unknown field ")
|
|
|
|
|
|
|
|
switch quotedField {
|
|
|
|
case `"Namespace"`:
|
|
|
|
return fmt.Errorf("%v - Namespaces is a Consul Enterprise feature", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
2017-11-28 16:06:26 -08:00
|
|
|
}
|
2019-12-13 14:50:07 -05:00
|
|
|
|
|
|
|
func (s *HTTPServer) addEnterpriseHTMLTemplateVars(vars map[string]interface{}) {}
|
2020-01-14 10:09:29 -05:00
|
|
|
|
|
|
|
func parseACLAuthMethodEnterpriseMeta(req *http.Request, _ *structs.ACLAuthMethodEnterpriseMeta) error {
|
|
|
|
if methodNS := req.URL.Query().Get("authmethod-ns"); methodNS != "" {
|
2020-01-27 05:00:33 -08:00
|
|
|
return BadRequestError{Reason: "Invalid query parameter: \"authmethod-ns\" - Namespaces is a Consul Enterprise feature"}
|
2020-01-14 10:09:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|