2022-03-27 10:59:30 +00:00
|
|
|
package dataplane
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
|
2022-03-27 10:59:30 +00:00
|
|
|
acl "github.com/hashicorp/consul/acl"
|
|
|
|
"github.com/hashicorp/consul/agent/grpc/public"
|
|
|
|
structs "github.com/hashicorp/consul/agent/structs"
|
|
|
|
"github.com/hashicorp/consul/proto-public/pbdataplane"
|
|
|
|
)
|
|
|
|
|
2022-04-20 00:24:21 +00:00
|
|
|
func (s *Server) GetSupportedDataplaneFeatures(ctx context.Context, req *pbdataplane.GetSupportedDataplaneFeaturesRequest) (*pbdataplane.GetSupportedDataplaneFeaturesResponse, error) {
|
|
|
|
logger := s.Logger.Named("get-supported-dataplane-features").With("request_id", public.TraceID())
|
|
|
|
|
|
|
|
logger.Trace("Started processing request")
|
|
|
|
defer logger.Trace("Finished processing request")
|
2022-03-27 10:59:30 +00:00
|
|
|
|
|
|
|
// Require the given ACL token to have `service:write` on any service
|
|
|
|
token := public.TokenFromContext(ctx)
|
|
|
|
var authzContext acl.AuthorizerContext
|
|
|
|
entMeta := structs.WildcardEnterpriseMetaInPartition(structs.WildcardSpecifier)
|
2022-04-20 00:24:21 +00:00
|
|
|
authz, err := s.ACLResolver.ResolveTokenAndDefaultMeta(token, entMeta, &authzContext)
|
2022-03-27 10:59:30 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.Unauthenticated, err.Error())
|
|
|
|
}
|
|
|
|
if err := authz.ToAllowAuthorizer().ServiceWriteAnyAllowed(&authzContext); err != nil {
|
|
|
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
supportedFeatures := []*pbdataplane.DataplaneFeatureSupport{
|
|
|
|
{
|
|
|
|
FeatureName: pbdataplane.DataplaneFeatures_WATCH_SERVERS,
|
|
|
|
Supported: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
FeatureName: pbdataplane.DataplaneFeatures_EDGE_CERTIFICATE_MANAGEMENT,
|
|
|
|
Supported: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
FeatureName: pbdataplane.DataplaneFeatures_ENVOY_BOOTSTRAP_CONFIGURATION,
|
|
|
|
Supported: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-04-20 00:24:21 +00:00
|
|
|
return &pbdataplane.GetSupportedDataplaneFeaturesResponse{SupportedDataplaneFeatures: supportedFeatures}, nil
|
2022-03-27 10:59:30 +00:00
|
|
|
}
|