2019-10-24 18:38:09 +00:00
|
|
|
// +build !consulent
|
|
|
|
|
2017-11-29 00:06:26 +00:00
|
|
|
package agent
|
|
|
|
|
2019-10-24 18:38:09 +00:00
|
|
|
import (
|
2019-12-06 16:14:56 +00:00
|
|
|
"fmt"
|
2019-10-24 18:38:09 +00:00
|
|
|
"net/http"
|
2019-12-06 16:14:56 +00:00
|
|
|
"strings"
|
2019-10-24 18:38:09 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
)
|
2018-02-18 01:31:24 +00:00
|
|
|
|
2019-12-06 16:14:56 +00:00
|
|
|
func (s *HTTPServer) parseEntMeta(req *http.Request, entMeta *structs.EnterpriseMeta) error {
|
|
|
|
if headerNS := req.Header.Get("X-Consul-Namespace"); headerNS != "" {
|
2020-06-23 16:57:30 +00:00
|
|
|
return BadRequestError{Reason: "Invalid header: \"X-Consul-Namespace\" - Namespaces are a Consul Enterprise feature"}
|
2019-12-06 16:14:56 +00:00
|
|
|
}
|
|
|
|
if queryNS := req.URL.Query().Get("ns"); queryNS != "" {
|
2020-06-23 16:57:30 +00:00
|
|
|
return BadRequestError{Reason: "Invalid query parameter: \"ns\" - Namespaces are a Consul Enterprise feature"}
|
2019-12-06 16:14:56 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-12-06 19:01:34 +00:00
|
|
|
func (s *HTTPServer) parseEntMetaNoWildcard(req *http.Request, _ *structs.EnterpriseMeta) error {
|
|
|
|
return s.parseEntMeta(req, nil)
|
|
|
|
}
|
|
|
|
|
2019-12-06 16:14:56 +00: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"`:
|
2020-06-23 16:57:30 +00:00
|
|
|
return fmt.Errorf("%v - Namespaces are a Consul Enterprise feature", err)
|
2019-12-06 16:14:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
2017-11-29 00:06:26 +00:00
|
|
|
}
|
2019-12-13 19:50:07 +00:00
|
|
|
|
|
|
|
func (s *HTTPServer) addEnterpriseHTMLTemplateVars(vars map[string]interface{}) {}
|
2020-01-14 15:09:29 +00:00
|
|
|
|
|
|
|
func parseACLAuthMethodEnterpriseMeta(req *http.Request, _ *structs.ACLAuthMethodEnterpriseMeta) error {
|
|
|
|
if methodNS := req.URL.Query().Get("authmethod-ns"); methodNS != "" {
|
2020-06-23 16:57:30 +00:00
|
|
|
return BadRequestError{Reason: "Invalid query parameter: \"authmethod-ns\" - Namespaces are a Consul Enterprise feature"}
|
2020-01-14 15:09:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-04-16 22:07:52 +00:00
|
|
|
|
2020-05-13 22:47:05 +00:00
|
|
|
// enterpriseHandler is a noop for the enterprise implementation. we pass the original back
|
|
|
|
func (s *HTTPServer) enterpriseHandler(next http.Handler) http.Handler {
|
|
|
|
return next
|
2020-04-16 22:07:52 +00:00
|
|
|
}
|