2022-03-27 16:29:30 +05:30
|
|
|
package dataplane
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-04-05 14:10:06 -07:00
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
|
2022-03-27 16:29:30 +05:30
|
|
|
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-19 17:24:21 -07: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 16:29:30 +05:30
|
|
|
|
|
|
|
// 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-19 17:24:21 -07:00
|
|
|
authz, err := s.ACLResolver.ResolveTokenAndDefaultMeta(token, entMeta, &authzContext)
|
2022-03-27 16:29:30 +05:30
|
|
|
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{
|
|
|
|
{
|
2022-05-23 10:37:52 -04:00
|
|
|
FeatureName: pbdataplane.DataplaneFeatures_DATAPLANE_FEATURES_WATCH_SERVERS,
|
2022-03-27 16:29:30 +05:30
|
|
|
Supported: true,
|
|
|
|
},
|
|
|
|
{
|
2022-05-23 10:37:52 -04:00
|
|
|
FeatureName: pbdataplane.DataplaneFeatures_DATAPLANE_FEATURES_EDGE_CERTIFICATE_MANAGEMENT,
|
2022-03-27 16:29:30 +05:30
|
|
|
Supported: true,
|
|
|
|
},
|
|
|
|
{
|
2022-05-23 10:37:52 -04:00
|
|
|
FeatureName: pbdataplane.DataplaneFeatures_DATAPLANE_FEATURES_ENVOY_BOOTSTRAP_CONFIGURATION,
|
2022-03-27 16:29:30 +05:30
|
|
|
Supported: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-04-19 17:24:21 -07:00
|
|
|
return &pbdataplane.GetSupportedDataplaneFeaturesResponse{SupportedDataplaneFeatures: supportedFeatures}, nil
|
2022-03-27 16:29:30 +05:30
|
|
|
}
|