From 1102e8f522d51c64e1ff3e0b43f7ab73a9f6b724 Mon Sep 17 00:00:00 2001 From: AmaliMatharaarachchi Date: Mon, 2 Sep 2024 10:44:57 +0530 Subject: [PATCH] Find matched api in enforcer --- .../proto/wso2/discovery/api/Resource.proto | 1 + .../api/proto/wso2/discovery/api/api.proto | 1 + .../discovery/config/enforcer/config.proto | 2 + adapter/config/default_config.go | 2 + adapter/config/types.go | 2 + adapter/internal/discovery/xds/marshaller.go | 2 + .../internal/oasparser/config_generator.go | 2 + .../envoyconf/envoyconf_internal_test.go | 8 +- .../oasparser/envoyconf/listener_test.go | 6 +- .../envoyconf/routes_with_clusters.go | 4 +- .../oasparser/model/adapter_internal_api.go | 11 +- .../internal/oasparser/model/api_operation.go | 13 +- adapter/internal/oasparser/model/common.go | 9 + .../internal/oasparser/model/http_route.go | 30 ++- .../kubernetes/proxy/resource.go | 8 +- .../v1alpha1/envoyproxy_helpers.go | 7 +- .../gateway-api/v1alpha1/shared_types.go | 2 - .../operator/gateway-api/version/version.go | 3 +- .../api/wso2/discovery/api/Resource.pb.go | 74 +++--- .../api/wso2/discovery/api/api.pb.go | 104 ++++---- .../discovery/config/enforcer/config.pb.go | 34 ++- .../commons/model/ResourceConfig.java | 16 ++ .../org/wso2/apk/enforcer/api/APIFactory.java | 46 +++- .../java/org/wso2/apk/enforcer/api/Utils.java | 4 +- .../apk/enforcer/config/ConfigHolder.java | 1 + .../apk/enforcer/config/EnforcerConfig.java | 10 + .../apk/enforcer/constants/APIConstants.java | 1 + .../wso2/apk/enforcer/discovery/api/Api.java | 238 ++++++++++++++++-- .../enforcer/discovery/api/ApiOrBuilder.java | 25 ++ .../apk/enforcer/discovery/api/ApiProto.java | 37 +-- .../apk/enforcer/discovery/api/Operation.java | 218 ++++++++++++---- .../discovery/api/OperationOrBuilder.java | 36 +-- .../enforcer/discovery/api/ResourceProto.java | 27 +- .../discovery/config/enforcer/Config.java | 65 +++++ .../config/enforcer/ConfigOrBuilder.java | 6 + .../config/enforcer/ConfigProto.java | 15 +- .../enforcer/graphql/GraphQLPayloadUtils.java | 13 +- .../enforcer/server/HttpRequestHandler.java | 15 +- .../wso2/apk/enforcer/util/EndpointUtils.java | 7 +- 39 files changed, 837 insertions(+), 268 deletions(-) diff --git a/adapter/api/proto/wso2/discovery/api/Resource.proto b/adapter/api/proto/wso2/discovery/api/Resource.proto index 45e4bfbb0..fac52a96c 100644 --- a/adapter/api/proto/wso2/discovery/api/Resource.proto +++ b/adapter/api/proto/wso2/discovery/api/Resource.proto @@ -46,6 +46,7 @@ message Operation { string tier = 3; OperationPolicies policies = 4; repeated string scopes = 5; + string matchID = 6; // MockedApiConfig mockedApiConfig = 6; } diff --git a/adapter/api/proto/wso2/discovery/api/api.proto b/adapter/api/proto/wso2/discovery/api/api.proto index 4e394e4dc..574fd78b6 100644 --- a/adapter/api/proto/wso2/discovery/api/api.proto +++ b/adapter/api/proto/wso2/discovery/api/api.proto @@ -53,6 +53,7 @@ message Api { string mutualSSL = 15; map applicationSecurity = 16; bool transportSecurity = 17; + repeated string httpRouteIDs = 19; /// string graphQLSchema = 22; repeated GraphqlComplexity graphqlComplexityInfo = 23; bool systemAPI = 24; diff --git a/adapter/api/proto/wso2/discovery/config/enforcer/config.proto b/adapter/api/proto/wso2/discovery/config/enforcer/config.proto index 9e7404f6d..595ec3911 100644 --- a/adapter/api/proto/wso2/discovery/config/enforcer/config.proto +++ b/adapter/api/proto/wso2/discovery/config/enforcer/config.proto @@ -53,4 +53,6 @@ message Config { bool mandateInternalKeyValidation = 15; + bool enableGatewayClassController = 16; + } diff --git a/adapter/config/default_config.go b/adapter/config/default_config.go index 887958c60..3b693d4d5 100644 --- a/adapter/config/default_config.go +++ b/adapter/config/default_config.go @@ -290,6 +290,8 @@ var defaultConfig = &Config{ CommonControllerXDSPort: "18002", CommonControllerRestPort: "18003", EnforcerLabel: "wso2-apk-default", + EnforcerImage: "wso2/apk-enforcer:1.1.0", + EnforcerImagePullPolicy: "Always", EnforcerRegion: "UNKNOWN", EnforcerXDSMaxMsgSize: "4194304", EnforcerXDSMaxRetries: "3", diff --git a/adapter/config/types.go b/adapter/config/types.go index 733bdefd8..4d86401bd 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -336,6 +336,8 @@ type gateway struct { CommonControllerRestPort string EnforcerLabel string EnforcerRegion string + EnforcerImage string + EnforcerImagePullPolicy string EnforcerXDSMaxMsgSize string EnforcerXDSMaxRetries string JavaOpts string diff --git a/adapter/internal/discovery/xds/marshaller.go b/adapter/internal/discovery/xds/marshaller.go index 7bfc4e805..2fe562c58 100644 --- a/adapter/internal/discovery/xds/marshaller.go +++ b/adapter/internal/discovery/xds/marshaller.go @@ -81,6 +81,7 @@ func MarshalConfig(config *config.Config) *enforcer.Config { } mandateSubscriptionValidation := config.Enforcer.MandateSubscriptionValidation mandateInternalKeyValidation := config.Enforcer.MandateInternalKeyValidation + enableGatewayClassController := config.Adapter.EnableGatewayClassController analytics := &enforcer.Analytics{ Enabled: config.Analytics.Enabled, @@ -160,6 +161,7 @@ func MarshalConfig(config *config.Config) *enforcer.Config { Soap: soap, MandateSubscriptionValidation: mandateSubscriptionValidation, MandateInternalKeyValidation: mandateInternalKeyValidation, + EnableGatewayClassController: enableGatewayClassController, HttpClient: httpClient, } } diff --git a/adapter/internal/oasparser/config_generator.go b/adapter/internal/oasparser/config_generator.go index 807fdd9cb..6018e999c 100644 --- a/adapter/internal/oasparser/config_generator.go +++ b/adapter/internal/oasparser/config_generator.go @@ -241,6 +241,7 @@ func GetEnforcerAPI(adapterInternalAPI *model.AdapterInternalAPI, vhost string) } return nil }(), + HttpRouteIDs: adapterInternalAPI.HTTPRouteIDs, } } @@ -263,6 +264,7 @@ func GetEnforcerAPIOperation(operation model.Operation, isMockedAPI bool) *api.O ApiAuthentication: castAPIAuthenticationsToEnforcerAPIAuthentications(operation.GetAuthentication()), Tier: operation.GetTier(), Policies: policies, + MatchID: operation.GetMatchID(), // MockedApiConfig: mockedAPIConfig, } return &apiOperation diff --git a/adapter/internal/oasparser/envoyconf/envoyconf_internal_test.go b/adapter/internal/oasparser/envoyconf/envoyconf_internal_test.go index 1be24e1da..bc6b9d8c2 100644 --- a/adapter/internal/oasparser/envoyconf/envoyconf_internal_test.go +++ b/adapter/internal/oasparser/envoyconf/envoyconf_internal_test.go @@ -72,7 +72,7 @@ func TestCreateRoute(t *testing.T) { }) resourceWithGet := model.CreateMinimalDummyResourceForTests("/xWso2BasePath/resourcePath", - []*model.Operation{model.NewOperationWithPolicies("GET", policies)}, + []*model.Operation{model.NewOperationWithPolicies("GET", policies, "")}, "resource_operation_id", []model.Endpoint{endpoint}, true, false) clusterName := "resource_operation_id" hostRewriteSpecifier := &routev3.RouteAction_AutoHostRewrite{ @@ -142,7 +142,7 @@ func TestCreateRouteClusterSpecifier(t *testing.T) { Port: 80, RawURL: "http://abc.com", } - resourceWithGet := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{model.NewOperation("GET", nil, nil)}, + resourceWithGet := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{model.NewOperation("GET", nil, nil, "")}, "resource_operation_id", []model.Endpoint{endpoint}, false, false) route, err := createRoutes(generateRouteCreateParamsForUnitTests(title, apiType, vHost, xWso2BasePath, version, endpointBasePath, @@ -173,7 +173,7 @@ func TestCreateRouteExtAuthzContext(t *testing.T) { Port: 80, RawURL: "http://abc.com", } - resourceWithGet := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{model.NewOperation("GET", nil, nil)}, + resourceWithGet := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{model.NewOperation("GET", nil, nil, "")}, "resource_operation_id", []model.Endpoint{endpoint}, false, false) route, err := createRoutes(generateRouteCreateParamsForUnitTests(title, apiType, vHost, xWso2BasePath, version, @@ -570,7 +570,7 @@ func TestGetCorsPolicy(t *testing.T) { "Cors Allowed Origin Header mismatch") assert.Empty(t, corsPolicy3.GetAllowCredentials(), "Allow Credential property should not be assigned.") - resourceWithGet := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{model.NewOperation("GET", nil, nil)}, + resourceWithGet := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{model.NewOperation("GET", nil, nil, "")}, "resource_operation_id", []model.Endpoint{endpoint}, false, false) // Route without CORS configuration diff --git a/adapter/internal/oasparser/envoyconf/listener_test.go b/adapter/internal/oasparser/envoyconf/listener_test.go index cf17e636e..46e60833b 100644 --- a/adapter/internal/oasparser/envoyconf/listener_test.go +++ b/adapter/internal/oasparser/envoyconf/listener_test.go @@ -196,9 +196,9 @@ func testCreateRoutesForUnitTests(t *testing.T) []*routev3.Route { RawURL: "http://abc.com", } - operationGet := model.NewOperation("GET", nil, nil) - operationPost := model.NewOperation("POST", nil, nil) - operationPut := model.NewOperation("PUT", nil, nil) + operationGet := model.NewOperation("GET", nil, nil, "") + operationPost := model.NewOperation("POST", nil, nil, "") + operationPut := model.NewOperation("PUT", nil, nil, "") resourceWithGet := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{operationGet}, "resource_operation_id", []model.Endpoint{endpoint}, false, false) resourceWithPost := model.CreateMinimalDummyResourceForTests("/resourcePath", []*model.Operation{operationPost}, diff --git a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go index b11ad5bed..cc0750aff 100644 --- a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go +++ b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go @@ -178,7 +178,7 @@ func CreateRoutesWithClusters(adapterInternalAPI *model.AdapterInternalAPI, inte }, }, } - gqlop := model.NewOperationWithPolicies("POST", policies) + gqlop := model.NewOperationWithPolicies("POST", policies, "") resource := model.CreateMinimalResource(adapterInternalAPI.GetXWso2Basepath(), []*model.Operation{gqlop}, "", adapterInternalAPI.Endpoints, true, false, gwapiv1.PathMatchExact) routesP, err := createRoutes(genRouteCreateParams(adapterInternalAPI, &resource, vHost, basePath, clusterName, nil, nil, organizationID, false, false, nil)) @@ -1074,7 +1074,7 @@ func createRoutes(params *routeCreateParams) (routes []*routev3.Route, err error } } if !hasOptions { - operations = append(operations, model.NewOperation("OPTIONS", nil, nil)) + operations = append(operations, model.NewOperation("OPTIONS", nil, nil, "")) } } diff --git a/adapter/internal/oasparser/model/adapter_internal_api.go b/adapter/internal/oasparser/model/adapter_internal_api.go index e861a0c95..27fcbad25 100644 --- a/adapter/internal/oasparser/model/adapter_internal_api.go +++ b/adapter/internal/oasparser/model/adapter_internal_api.go @@ -82,6 +82,7 @@ type AdapterInternalAPI struct { Endpoints *EndpointCluster EndpointSecurity []*EndpointSecurity AIProvider InternalAIProvider + HTTPRouteIDs []string } // BackendJWTTokenInfo represents the object structure holding the information related to the JWT Generator @@ -889,7 +890,11 @@ func (adapterInternalAPI *AdapterInternalAPI) SetInfoHTTPRouteCR(httpRoute *gwap loggers.LoggerOasparser.Debugf("Calculating auths for API ..., API_UUID = %v", adapterInternalAPI.UUID) apiAuth := getSecurity(resourceAuthScheme) - for _, match := range rule.Matches { + if !hasRequestRedirectPolicy && len(rule.BackendRefs) < 1 { + return fmt.Errorf("no backendref were provided") + } + + for matchID, match := range rule.Matches { if hasURLRewritePolicy && hasRequestRedirectPolicy { return fmt.Errorf("cannot have URL Rewrite and Request Redirect under the same rule") } @@ -909,8 +914,8 @@ func (adapterInternalAPI *AdapterInternalAPI) SetInfoHTTPRouteCR(httpRoute *gwap }) } resourcePath := adapterInternalAPI.xWso2Basepath + *match.Path.Value - - operations := getAllowedOperations(match.Method, policies, apiAuth, + matchID := getMatchID(httpRoute.Namespace, httpRoute.Name, ruleID, matchID) + operations := getAllowedOperations(matchID, match.Method, policies, apiAuth, parseRateLimitPolicyToInternal(resourceRatelimitPolicy), scopes, mirrorEndpointClusters) resource := &Resource{ diff --git a/adapter/internal/oasparser/model/api_operation.go b/adapter/internal/oasparser/model/api_operation.go index 6220dbeb6..899a8fb02 100644 --- a/adapter/internal/oasparser/model/api_operation.go +++ b/adapter/internal/oasparser/model/api_operation.go @@ -44,6 +44,7 @@ type Operation struct { mockedAPIConfig *api.MockedApiConfig rateLimitPolicy *RateLimitPolicy mirrorEndpointClusters []*EndpointCluster + matchID string } // Authentication holds authentication related configurations @@ -109,6 +110,10 @@ func (operation *Operation) GetTier() string { return operation.tier } +func (operation *Operation) GetMatchID() string { + return operation.matchID +} + // GetMockedAPIConfig returns the operation level mocked API implementation configs func (operation *Operation) GetMockedAPIConfig() *api.MockedApiConfig { return operation.mockedAPIConfig @@ -176,14 +181,14 @@ func (operation *Operation) GetCallInterceptorService(isIn bool) InterceptEndpoi } // NewOperation Creates and returns operation type object -func NewOperation(method string, security []string, extensions map[string]interface{}) *Operation { +func NewOperation(method string, security []string, extensions map[string]interface{}, matchID string) *Operation { tier := ResolveThrottlingTier(extensions) disableSecurity := ResolveDisableSecurity(extensions) id := uuid.New().String() - return &Operation{id, method, security, nil, tier, disableSecurity, extensions, OperationPolicies{}, &api.MockedApiConfig{}, nil, nil} + return &Operation{id, method, security, nil, tier, disableSecurity, extensions, OperationPolicies{}, &api.MockedApiConfig{}, nil, nil, matchID} } // NewOperationWithPolicies Creates and returns operation with given method and policies -func NewOperationWithPolicies(method string, policies OperationPolicies) *Operation { - return &Operation{iD: uuid.New().String(), method: method, policies: policies} +func NewOperationWithPolicies(method string, policies OperationPolicies, matchID string) *Operation { + return &Operation{iD: uuid.New().String(), method: method, policies: policies, matchID: matchID} } diff --git a/adapter/internal/oasparser/model/common.go b/adapter/internal/oasparser/model/common.go index 8c5c2f54c..53ef4f4a1 100644 --- a/adapter/internal/oasparser/model/common.go +++ b/adapter/internal/oasparser/model/common.go @@ -22,6 +22,7 @@ package model import ( "errors" + "fmt" "net/url" "regexp" "strconv" @@ -155,3 +156,11 @@ func getHostandBasepathandPort(apiType string, rawURL string) (*Endpoint, error) return &Endpoint{Host: host, Basepath: basepath, Port: port, URLType: urlType, RawURL: rawURL}, nil } + +func getRouteID(namespace, name string) string { + return fmt.Sprintf("httproute/%s/%s/", namespace, name) +} + +func getMatchID(namespace, name string, ruleID, matchID int) string { + return fmt.Sprintf("%srule/%d/match/%d", getRouteID(namespace, name), ruleID, matchID) +} diff --git a/adapter/internal/oasparser/model/http_route.go b/adapter/internal/oasparser/model/http_route.go index 6092dd66b..8aec6aa6a 100644 --- a/adapter/internal/oasparser/model/http_route.go +++ b/adapter/internal/oasparser/model/http_route.go @@ -287,26 +287,26 @@ func getSecurity(authScheme *dpv1alpha2.Authentication) *Authentication { } // getAllowedOperations retuns a list of allowed operatons, if httpMethod is not specified then all methods are allowed. -func getAllowedOperations(httpMethod *gwapiv1.HTTPMethod, policies OperationPolicies, auth *Authentication, +func getAllowedOperations(matchID string, httpMethod *gwapiv1.HTTPMethod, policies OperationPolicies, auth *Authentication, ratelimitPolicy *RateLimitPolicy, scopes []string, mirrorEndpointClusters []*EndpointCluster) []*Operation { if httpMethod != nil { return []*Operation{{iD: uuid.New().String(), method: string(*httpMethod), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters}} + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters, matchID: matchID}} } return []*Operation{{iD: uuid.New().String(), method: string(gwapiv1.HTTPMethodGet), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes}, + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, matchID: matchID}, {iD: uuid.New().String(), method: string(gwapiv1.HTTPMethodPost), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters}, + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters, matchID: matchID}, {iD: uuid.New().String(), method: string(gwapiv1.HTTPMethodDelete), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters}, + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters, matchID: matchID}, {iD: uuid.New().String(), method: string(gwapiv1.HTTPMethodPatch), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters}, + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters, matchID: matchID}, {iD: uuid.New().String(), method: string(gwapiv1.HTTPMethodPut), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters}, + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters, matchID: matchID}, {iD: uuid.New().String(), method: string(gwapiv1.HTTPMethodHead), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters}, + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters, matchID: matchID}, {iD: uuid.New().String(), method: string(gwapiv1.HTTPMethodOptions), policies: policies, - auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters}} + auth: auth, rateLimitPolicy: ratelimitPolicy, scopes: scopes, mirrorEndpointClusters: mirrorEndpointClusters, matchID: matchID}} } // SetInfoAPICR populates ID, ApiType, Version and XWso2BasePath of adapterInternalAPI. @@ -319,4 +319,16 @@ func (swagger *AdapterInternalAPI) SetInfoAPICR(api dpv1alpha3.API) { swagger.OrganizationID = api.Spec.Organization swagger.IsSystemAPI = api.Spec.SystemAPI swagger.APIProperties = api.Spec.APIProperties + httpRouteIDs := []string{} + for _, route := range api.Spec.Production { + for _, routeRef := range route.RouteRefs { + httpRouteIDs = append(httpRouteIDs, getRouteID(api.Namespace, routeRef)) + } + } + for _, route := range api.Spec.Sandbox { + for _, routeRef := range route.RouteRefs { + httpRouteIDs = append(httpRouteIDs, getRouteID(api.Namespace, routeRef)) + } + } + swagger.HTTPRouteIDs = httpRouteIDs } diff --git a/adapter/internal/operator/gateway-api/infrastructure/kubernetes/proxy/resource.go b/adapter/internal/operator/gateway-api/infrastructure/kubernetes/proxy/resource.go index 631f4f357..c00b77c78 100644 --- a/adapter/internal/operator/gateway-api/infrastructure/kubernetes/proxy/resource.go +++ b/adapter/internal/operator/gateway-api/infrastructure/kubernetes/proxy/resource.go @@ -272,11 +272,9 @@ func expectedProxyContainers(infra *ir.ProxyInfra, }, }, { - Name: enforcerContainerName, - Image: *deploymentConfig.EnforcerContainer.Image, - ImagePullPolicy: corev1.PullIfNotPresent, - // Command: []string{"envoy"}, - // Args: args, + Name: enforcerContainerName, + Image: *deploymentConfig.EnforcerContainer.Image, + ImagePullPolicy: corev1.PullPolicy(config.ReadConfigs().Deployment.Gateway.EnforcerImagePullPolicy), Env: expectedEnforcerEnv(deploymentConfig.EnforcerContainer), Resources: *deploymentConfig.EnforcerContainer.Resources, SecurityContext: deploymentConfig.EnforcerContainer.SecurityContext, diff --git a/adapter/internal/operator/gateway-api/v1alpha1/envoyproxy_helpers.go b/adapter/internal/operator/gateway-api/v1alpha1/envoyproxy_helpers.go index 666f39b99..b9df57fef 100644 --- a/adapter/internal/operator/gateway-api/v1alpha1/envoyproxy_helpers.go +++ b/adapter/internal/operator/gateway-api/v1alpha1/envoyproxy_helpers.go @@ -27,6 +27,7 @@ import ( "sort" "strings" + "github.com/wso2/apk/adapter/config" autoscalingv2 "k8s.io/api/autoscaling/v2" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -54,7 +55,7 @@ func (e *EnvoyProxy) GetEnvoyProxyProvider() *EnvoyProxyProvider { // DefaultEnvoyProxyKubeProvider returns a new EnvoyProxyKubernetesProvider with default settings. func DefaultEnvoyProxyKubeProvider() *EnvoyProxyKubernetesProvider { return &EnvoyProxyKubernetesProvider{ - EnvoyDeployment: DefaultKubernetesDeployment(DefaultEnvoyProxyImage, DefaultEnforcerImage), + EnvoyDeployment: DefaultKubernetesDeployment(DefaultEnvoyProxyImage, config.ReadConfigs().Deployment.Gateway.EnforcerImage), EnvoyService: DefaultKubernetesService(), } } @@ -88,10 +89,10 @@ func (r *EnvoyProxyProvider) GetEnvoyProxyKubeProvider() *EnvoyProxyKubernetesPr } if r.Kubernetes.EnvoyDeployment == nil { - r.Kubernetes.EnvoyDeployment = DefaultKubernetesDeployment(DefaultEnvoyProxyImage, DefaultEnforcerImage) + r.Kubernetes.EnvoyDeployment = DefaultKubernetesDeployment(DefaultEnvoyProxyImage, config.ReadConfigs().Deployment.Gateway.EnforcerImage) } - r.Kubernetes.EnvoyDeployment.defaultKubernetesDeploymentSpec(DefaultEnvoyProxyImage, DefaultEnforcerImage) + r.Kubernetes.EnvoyDeployment.defaultKubernetesDeploymentSpec(DefaultEnvoyProxyImage, config.ReadConfigs().Deployment.Gateway.EnforcerImage) if r.Kubernetes.EnvoyService == nil { r.Kubernetes.EnvoyService = DefaultKubernetesService() diff --git a/adapter/internal/operator/gateway-api/v1alpha1/shared_types.go b/adapter/internal/operator/gateway-api/v1alpha1/shared_types.go index 72fcdddbd..3030803b7 100644 --- a/adapter/internal/operator/gateway-api/v1alpha1/shared_types.go +++ b/adapter/internal/operator/gateway-api/v1alpha1/shared_types.go @@ -38,8 +38,6 @@ const ( DefaultDeploymentMemoryResourceRequests = "512Mi" // DefaultEnvoyProxyImage is the default image used by envoyproxy DefaultEnvoyProxyImage = "envoyproxy/envoy:distroless-v1.29.3" - // DefaultEnforcerImage default image used by enforcer - DefaultEnforcerImage = "wso2/apk-enforcer:1.1.0" // DefaultShutdownManagerCPUResourceRequests for shutdown manager cpu resource DefaultShutdownManagerCPUResourceRequests = "10m" // DefaultShutdownManagerMemoryResourceRequests for shutdown manager memory resource diff --git a/adapter/internal/operator/gateway-api/version/version.go b/adapter/internal/operator/gateway-api/version/version.go index f320a6c07..f81bae213 100644 --- a/adapter/internal/operator/gateway-api/version/version.go +++ b/adapter/internal/operator/gateway-api/version/version.go @@ -29,6 +29,7 @@ import ( "runtime/debug" "strings" + "github.com/wso2/apk/adapter/config" "github.com/wso2/apk/adapter/internal/operator/gateway-api/v1alpha1" "sigs.k8s.io/yaml" ) @@ -57,7 +58,7 @@ var ( envoyGatewayVersion string gatewayAPIVersion string envoyProxyVersion = strings.Split(v1alpha1.DefaultEnvoyProxyImage, ":")[1] - enforcerVersion = strings.Split(v1alpha1.DefaultEnforcerImage, ":")[1] + enforcerVersion = strings.Split(config.ReadConfigs().Deployment.Gateway.EnforcerImage, ":")[1] shutdownManagerVersion string gitCommitID string ) diff --git a/adapter/pkg/discovery/api/wso2/discovery/api/Resource.pb.go b/adapter/pkg/discovery/api/wso2/discovery/api/Resource.pb.go index 8550adea6..83c7c0ece 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/api/Resource.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/api/Resource.pb.go @@ -126,7 +126,8 @@ type Operation struct { ApiAuthentication *APIAuthentication `protobuf:"bytes,2,opt,name=apiAuthentication,proto3" json:"apiAuthentication,omitempty"` Tier string `protobuf:"bytes,3,opt,name=tier,proto3" json:"tier,omitempty"` Policies *OperationPolicies `protobuf:"bytes,4,opt,name=policies,proto3" json:"policies,omitempty"` - Scopes []string `protobuf:"bytes,5,rep,name=scopes,proto3" json:"scopes,omitempty"` // MockedApiConfig mockedApiConfig = 6; + Scopes []string `protobuf:"bytes,5,rep,name=scopes,proto3" json:"scopes,omitempty"` + MatchID string `protobuf:"bytes,6,opt,name=matchID,proto3" json:"matchID,omitempty"` // MockedApiConfig mockedApiConfig = 6; } func (x *Operation) Reset() { @@ -196,6 +197,13 @@ func (x *Operation) GetScopes() []string { return nil } +func (x *Operation) GetMatchID() string { + if x != nil { + return x.MatchID + } + return "" +} + // OperationPolicies holds policies of the APIM operations type OperationPolicies struct { state protoimpl.MessageState @@ -346,7 +354,7 @@ var file_wso2_discovery_api_Resource_proto_rawDesc = []byte{ 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x22, 0xe7, 0x01, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x74, 0x79, 0x22, 0x81, 0x02, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x53, 0x0a, 0x11, 0x61, 0x70, 0x69, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, @@ -360,37 +368,39 @@ var file_wso2_discovery_api_Resource_proto_rawDesc = []byte{ 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x22, 0xb3, 0x01, 0x0a, - 0x11, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, - 0x65, 0x73, 0x12, 0x34, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, - 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, - 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x36, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x77, 0x73, 0x6f, - 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x30, 0x0a, 0x05, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x05, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x22, 0xab, 0x01, 0x0a, 0x06, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x16, 0x0a, - 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4a, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x61, 0x74, 0x63, 0x68, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x61, 0x74, 0x63, 0x68, 0x49, 0x44, 0x22, 0xb3, 0x01, 0x0a, 0x11, 0x4f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x07, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x36, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, - 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x42, 0x75, 0x0a, 0x23, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, - 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x42, 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, - 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, - 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, - 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x05, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x22, 0xab, 0x01, 0x0a, + 0x06, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x4a, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x75, 0x0a, 0x23, 0x6f, 0x72, + 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, + 0x69, 0x42, 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, + 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, + 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, + 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go b/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go index 8f785e8a2..5a3e1238b 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go @@ -60,6 +60,7 @@ type Api struct { MutualSSL string `protobuf:"bytes,15,opt,name=mutualSSL,proto3" json:"mutualSSL,omitempty"` ApplicationSecurity map[string]bool `protobuf:"bytes,16,rep,name=applicationSecurity,proto3" json:"applicationSecurity,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` TransportSecurity bool `protobuf:"varint,17,opt,name=transportSecurity,proto3" json:"transportSecurity,omitempty"` + HttpRouteIDs []string `protobuf:"bytes,19,rep,name=httpRouteIDs,proto3" json:"httpRouteIDs,omitempty"` /// string graphQLSchema = 22; GraphqlComplexityInfo []*GraphqlComplexity `protobuf:"bytes,23,rep,name=graphqlComplexityInfo,proto3" json:"graphqlComplexityInfo,omitempty"` SystemAPI bool `protobuf:"varint,24,opt,name=systemAPI,proto3" json:"systemAPI,omitempty"` @@ -223,6 +224,13 @@ func (x *Api) GetTransportSecurity() bool { return false } +func (x *Api) GetHttpRouteIDs() []string { + if x != nil { + return x.HttpRouteIDs + } + return nil +} + func (x *Api) GetGraphqlComplexityInfo() []*GraphqlComplexity { if x != nil { return x.GraphqlComplexityInfo @@ -309,7 +317,7 @@ var file_wso2_discovery_api_api_proto_rawDesc = []byte{ 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x24, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x69, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa7, 0x0a, 0x0a, 0x03, 0x41, 0x70, 0x69, 0x12, 0x0e, 0x0a, 0x02, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcb, 0x0a, 0x0a, 0x03, 0x41, 0x70, 0x69, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, @@ -352,54 +360,56 @@ var file_wso2_discovery_api_api_proto_rawDesc = []byte{ 0x6e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2c, 0x0a, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x5b, 0x0a, 0x15, 0x67, 0x72, 0x61, 0x70, 0x68, - 0x71, 0x6c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, - 0x18, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x72, 0x61, 0x70, - 0x68, 0x71, 0x6c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x74, 0x79, 0x52, 0x15, 0x67, + 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x52, + 0x6f, 0x75, 0x74, 0x65, 0x49, 0x44, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x68, + 0x74, 0x74, 0x70, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x49, 0x44, 0x73, 0x12, 0x5b, 0x0a, 0x15, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x74, 0x79, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x50, - 0x49, 0x18, 0x18, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, - 0x50, 0x49, 0x12, 0x59, 0x0a, 0x13, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x4a, 0x57, 0x54, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x27, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x4a, 0x57, 0x54, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x13, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, - 0x64, 0x4a, 0x57, 0x54, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2c, 0x0a, - 0x11, 0x61, 0x70, 0x69, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, - 0x6c, 0x65, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x61, 0x70, 0x69, 0x44, 0x65, 0x66, - 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x65, - 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x36, 0x0a, - 0x16, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x73, - 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x73, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, - 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x45, 0x6e, - 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x09, 0x65, - 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x4c, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x1e, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x65, - 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x3e, 0x0a, 0x0a, 0x61, 0x69, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x18, 0x1f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x77, 0x73, 0x6f, + 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x41, 0x49, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x61, 0x69, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x1a, 0x46, 0x0a, 0x18, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x70, - 0x0a, 0x23, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, - 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, - 0x79, 0x2e, 0x61, 0x70, 0x69, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, - 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x47, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x74, + 0x79, 0x52, 0x15, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, + 0x78, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x41, 0x50, 0x49, 0x18, 0x18, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x41, 0x50, 0x49, 0x12, 0x59, 0x0a, 0x13, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, + 0x64, 0x4a, 0x57, 0x54, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x19, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, + 0x4a, 0x57, 0x54, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x13, 0x62, 0x61, + 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x4a, 0x57, 0x54, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x2c, 0x0a, 0x11, 0x61, 0x70, 0x69, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x61, 0x70, + 0x69, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x1b, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, + 0x74, 0x12, 0x36, 0x0a, 0x16, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1c, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x16, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x09, 0x65, 0x6e, 0x64, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x77, + 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x4c, 0x0a, 0x10, + 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x18, 0x1e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x63, 0x75, + 0x72, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x3e, 0x0a, 0x0a, 0x61, 0x69, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x1f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, + 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x41, 0x49, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x0a, + 0x61, 0x69, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x1a, 0x46, 0x0a, 0x18, 0x41, 0x70, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, + 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x42, 0x70, 0x0a, 0x23, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, + 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, + 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, + 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/config.pb.go b/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/config.pb.go index 0f0eca465..37011525c 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/config.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/config.pb.go @@ -41,6 +41,7 @@ type Config struct { MandateSubscriptionValidation bool `protobuf:"varint,13,opt,name=mandateSubscriptionValidation,proto3" json:"mandateSubscriptionValidation,omitempty"` HttpClient *HttpClient `protobuf:"bytes,14,opt,name=httpClient,proto3" json:"httpClient,omitempty"` MandateInternalKeyValidation bool `protobuf:"varint,15,opt,name=mandateInternalKeyValidation,proto3" json:"mandateInternalKeyValidation,omitempty"` + EnableGatewayClassController bool `protobuf:"varint,16,opt,name=enableGatewayClassController,proto3" json:"enableGatewayClassController,omitempty"` } func (x *Config) Reset() { @@ -180,6 +181,13 @@ func (x *Config) GetMandateInternalKeyValidation() bool { return false } +func (x *Config) GetEnableGatewayClassController() bool { + if x != nil { + return x.EnableGatewayClassController + } + return false +} + var File_wso2_discovery_config_enforcer_config_proto protoreflect.FileDescriptor var file_wso2_discovery_config_enforcer_config_proto_rawDesc = []byte{ @@ -222,7 +230,7 @@ var file_wso2_discovery_config_enforcer_config_proto_rawDesc = []byte{ 0x73, 0x6f, 0x61, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2b, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa7, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, + 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xeb, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x44, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, @@ -289,16 +297,20 @@ var file_wso2_discovery_config_enforcer_config_proto_rawDesc = []byte{ 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x6d, 0x61, 0x6e, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x42, 0x90, 0x01, 0x0a, 0x2f, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, - 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, - 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, - 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, - 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x12, 0x42, 0x0a, 0x1c, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, + 0x61, 0x79, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, + 0x72, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x47, + 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x42, 0x90, 0x01, 0x0a, 0x2f, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, + 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, + 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, + 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, + 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/ResourceConfig.java b/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/ResourceConfig.java index e70bc8559..27970a96e 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/ResourceConfig.java +++ b/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/ResourceConfig.java @@ -27,6 +27,7 @@ public class ResourceConfig { private String path; + private String matchID; private HttpMethods method; private String tier = "Unlimited"; private EndpointCluster endpoints; @@ -51,6 +52,19 @@ private HttpMethods(String value) { } } + /** + * Get the matching path Template for the request. + * + * @return path Template + */ + public String getMatchID() { + return matchID; + } + + public void setMatchID(String matchID) { + this.matchID = matchID; + } + /** * Get the matching path Template for the request. * @@ -91,6 +105,7 @@ public void setTier(String tier) { } //todo(amali) this don't need to be a map + /** * Get the resource level endpoint cluster map for the corresponding Resource * where the map-key is either "PRODUCTION" or "SANDBOX". @@ -133,6 +148,7 @@ public String[] getScopes() { public void setScopes(String[] scopes) { this.scopes = scopes; } + public PolicyConfig getPolicyConfig() { return policyConfig; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/APIFactory.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/APIFactory.java index ec2dc512e..85b78d5e6 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/APIFactory.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/APIFactory.java @@ -21,6 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.wso2.apk.enforcer.common.CacheProviderUtil; +import org.wso2.apk.enforcer.config.ConfigHolder; +import org.wso2.apk.enforcer.config.EnforcerConfig; import org.wso2.apk.enforcer.discovery.api.Api; import org.wso2.apk.enforcer.commons.model.APIConfig; import org.wso2.apk.enforcer.commons.model.ResourceConfig; @@ -65,7 +67,7 @@ public void addApi(API api) { public void addApis(List apis) { //TODO: (Praminda) Use apiId as the map key. Need to add the apiId to envoy context meta Map newApis = new ConcurrentHashMap<>(); - + EnforcerConfig enforcerConfig = ConfigHolder.getInstance().getConfig(); for (Api api : apis) { // if (APIConstants.ApiType.WEB_SOCKET.equals(api.getApiType())) { // WebSocketAPI webSocketAPI = new WebSocketAPI(); @@ -76,18 +78,36 @@ public void addApis(List apis) { if (APIConstants.ApiType.GRAPHQL.equals(api.getApiType())) { GraphQLAPI graphQLAPI = new GraphQLAPI(); graphQLAPI.init(api); - String apiKey = getApiKey(graphQLAPI); - newApis.put(apiKey, graphQLAPI); + if (enforcerConfig.getEnableGatewayClassController()) { + for (String httpRouteID : api.getHttpRouteIDsList()) { + newApis.put(httpRouteID, graphQLAPI); + } + } else { + String apiKey = getApiKey(graphQLAPI); + newApis.put(apiKey, graphQLAPI); + } } else if (APIConstants.ApiType.GRPC.equals(api.getApiType())) { GRPCAPI grpcAPI = new GRPCAPI(); grpcAPI.init(api); - String apiKey = getApiKey(grpcAPI); - newApis.put(apiKey, grpcAPI); + if (enforcerConfig.getEnableGatewayClassController()) { + for (String httpRouteID : api.getHttpRouteIDsList()) { + newApis.put(httpRouteID, grpcAPI); + } + } else { + String apiKey = getApiKey(grpcAPI); + newApis.put(apiKey, grpcAPI); + } } else { RestAPI enforcerApi = new RestAPI(); enforcerApi.init(api); - String apiKey = getApiKey(enforcerApi); - newApis.put(apiKey, enforcerApi); + if (enforcerConfig.getEnableGatewayClassController()) { + for (String httpRouteID : api.getHttpRouteIDsList()) { + newApis.put(httpRouteID, enforcerApi); + } + } else { + String apiKey = getApiKey(enforcerApi); + newApis.put(apiKey, enforcerApi); + } } } @@ -104,6 +124,12 @@ public void removeApi(API api) { } public API getMatchedAPI(CheckRequest request) { + EnforcerConfig enforcerConfig = ConfigHolder.getInstance().getConfig(); + if (enforcerConfig.getEnableGatewayClassController()) { + String routeName = request.getAttributes().getContextExtensionsMap().get(APIConstants.ROUTE_NAME_PARAM); + String apikey = routeName.split("rule/")[0]; + return apis.get(apikey); + } String vHost = request.getAttributes().getContextExtensionsMap().get(APIConstants.GW_VHOST_PARAM); String basePath = request.getAttributes().getContextExtensionsMap().get(APIConstants.GW_BASE_PATH_PARAM); String version = request.getAttributes().getContextExtensionsMap().get(APIConstants.GW_VERSION_PARAM); @@ -136,6 +162,12 @@ public byte[] getAPIDefinition(final String basePath, final String version, fina // return (WebSocketAPI) apis.get(apiKey); // } + public ResourceConfig getMatchedResource(API api, String routeName) { + List resourceConfigList = api.getAPIConfig().getResources(); + return resourceConfigList.stream() + .filter(resourceConfig -> routeName.startsWith(resourceConfig.getMatchID()+"/")).findFirst().orElse(null); + } + public ResourceConfig getMatchedResource(API api, String matchedResourcePath, String method) { List resourceConfigList = api.getAPIConfig().getResources(); if (APIConstants.ApiType.GRPC.equals(api.getAPIConfig().getApiType())) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/Utils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/Utils.java index c2b2d46bb..c43997aab 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/Utils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/Utils.java @@ -21,6 +21,7 @@ import org.wso2.apk.enforcer.commons.model.AuthenticationConfig; import org.wso2.apk.enforcer.commons.model.JWTAuthenticationConfig; import org.wso2.apk.enforcer.commons.model.Oauth2AuthenticationConfig; +import org.wso2.apk.enforcer.config.EnforcerConfig; import org.wso2.apk.enforcer.discovery.api.APIKey; import org.wso2.apk.enforcer.discovery.api.EndpointClusterConfig; import org.wso2.apk.enforcer.discovery.api.Operation; @@ -87,6 +88,7 @@ public static EndpointCluster processEndpoints(org.wso2.apk.enforcer.discovery.a public static ResourceConfig buildResource(Operation operation, String resPath, EndpointSecurity[] endpointSecurity) { ResourceConfig resource = new ResourceConfig(); + resource.setMatchID(operation.getMatchID()); resource.setPath(resPath); resource.setMethod(ResourceConfig.HttpMethods.valueOf(operation.getMethod().toUpperCase())); resource.setTier(operation.getTier()); @@ -98,7 +100,7 @@ public static ResourceConfig buildResource(Operation operation, String resPath, JWTAuthenticationConfig jwtAuthenticationConfig = getDefaultJwtAuthenticationConfig(); authenticationConfig.setJwtAuthenticationConfig(jwtAuthenticationConfig); } - + if (operation.hasApiAuthentication()) { authenticationConfig.setDisabled(operation.getApiAuthentication().getDisabled()); if (operation.getApiAuthentication().hasOauth2()) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java index 238f74491..2adaf1563 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java @@ -175,6 +175,7 @@ private void parseConfigs(Config config) { populateMandateSubscriptionValidationConfig(config.getMandateSubscriptionValidation()); populateMandateInternalKeyValidationConfig(config.getMandateInternalKeyValidation()); populateHttpClientConfig(config.getHttpClient()); + this.config.setEnableGatewayClassController(config.getEnableGatewayClassController()); // resolve string variables provided as environment variables. resolveConfigsWithEnvs(this.config); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnforcerConfig.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnforcerConfig.java index c8eeb7586..789634146 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnforcerConfig.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnforcerConfig.java @@ -63,7 +63,17 @@ public class EnforcerConfig { private boolean mandateSubscriptionValidation; private boolean mandateInternalKeyValidation; private ClientConfigDto httpClientConfigDto; + private boolean enableGatewayClassController; + public void setEnableGatewayClassController(Boolean enableGatewayClassController) { + + this.enableGatewayClassController = enableGatewayClassController; + } + + public Boolean getEnableGatewayClassController() { + + return enableGatewayClassController; + } public ClientConfigDto getHttpClientConfigDto() { return httpClientConfigDto; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java index ddb0a747f..4e6da2259 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java @@ -26,6 +26,7 @@ public class APIConstants { public static final String DEFAULT = "default"; public static final String GW_VHOST_PARAM = "vHost"; + public static final String ROUTE_NAME_PARAM = "route-name"; public static final String GW_BASE_PATH_PARAM = "basePath"; public static final String GW_RES_PATH_PARAM = "path"; public static final String GW_VERSION_PARAM = "version"; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java index 508410367..d72826742 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java @@ -33,6 +33,7 @@ private Api() { organizationId_ = ""; clientCertificates_ = java.util.Collections.emptyList(); mutualSSL_ = ""; + httpRouteIDs_ = com.google.protobuf.LazyStringArrayList.EMPTY; graphqlComplexityInfo_ = java.util.Collections.emptyList(); apiDefinitionFile_ = com.google.protobuf.ByteString.EMPTY; environment_ = ""; @@ -182,11 +183,20 @@ private Api( transportSecurity_ = input.readBool(); break; } - case 186: { + case 154: { + java.lang.String s = input.readStringRequireUtf8(); if (!((mutable_bitField0_ & 0x00000008) != 0)) { - graphqlComplexityInfo_ = new java.util.ArrayList(); + httpRouteIDs_ = new com.google.protobuf.LazyStringArrayList(); mutable_bitField0_ |= 0x00000008; } + httpRouteIDs_.add(s); + break; + } + case 186: { + if (!((mutable_bitField0_ & 0x00000010) != 0)) { + graphqlComplexityInfo_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } graphqlComplexityInfo_.add( input.readMessage(org.wso2.apk.enforcer.discovery.api.GraphqlComplexity.parser(), extensionRegistry)); break; @@ -239,9 +249,9 @@ private Api( break; } case 242: { - if (!((mutable_bitField0_ & 0x00000010) != 0)) { + if (!((mutable_bitField0_ & 0x00000020) != 0)) { endpointSecurity_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; + mutable_bitField0_ |= 0x00000020; } endpointSecurity_.add( input.readMessage(org.wso2.apk.enforcer.discovery.api.SecurityInfo.parser(), extensionRegistry)); @@ -282,9 +292,12 @@ private Api( clientCertificates_ = java.util.Collections.unmodifiableList(clientCertificates_); } if (((mutable_bitField0_ & 0x00000008) != 0)) { - graphqlComplexityInfo_ = java.util.Collections.unmodifiableList(graphqlComplexityInfo_); + httpRouteIDs_ = httpRouteIDs_.getUnmodifiableView(); } if (((mutable_bitField0_ & 0x00000010) != 0)) { + graphqlComplexityInfo_ = java.util.Collections.unmodifiableList(graphqlComplexityInfo_); + } + if (((mutable_bitField0_ & 0x00000020) != 0)) { endpointSecurity_ = java.util.Collections.unmodifiableList(endpointSecurity_); } this.unknownFields = unknownFields.build(); @@ -948,6 +961,41 @@ public boolean getTransportSecurity() { return transportSecurity_; } + public static final int HTTPROUTEIDS_FIELD_NUMBER = 19; + private com.google.protobuf.LazyStringList httpRouteIDs_; + /** + * repeated string httpRouteIDs = 19; + * @return A list containing the httpRouteIDs. + */ + public com.google.protobuf.ProtocolStringList + getHttpRouteIDsList() { + return httpRouteIDs_; + } + /** + * repeated string httpRouteIDs = 19; + * @return The count of httpRouteIDs. + */ + public int getHttpRouteIDsCount() { + return httpRouteIDs_.size(); + } + /** + * repeated string httpRouteIDs = 19; + * @param index The index of the element to return. + * @return The httpRouteIDs at the given index. + */ + public java.lang.String getHttpRouteIDs(int index) { + return httpRouteIDs_.get(index); + } + /** + * repeated string httpRouteIDs = 19; + * @param index The index of the value to return. + * @return The bytes of the httpRouteIDs at the given index. + */ + public com.google.protobuf.ByteString + getHttpRouteIDsBytes(int index) { + return httpRouteIDs_.getByteString(index); + } + public static final int GRAPHQLCOMPLEXITYINFO_FIELD_NUMBER = 23; private java.util.List graphqlComplexityInfo_; /** @@ -1265,6 +1313,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (transportSecurity_ != false) { output.writeBool(17, transportSecurity_); } + for (int i = 0; i < httpRouteIDs_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 19, httpRouteIDs_.getRaw(i)); + } for (int i = 0; i < graphqlComplexityInfo_.size(); i++) { output.writeMessage(23, graphqlComplexityInfo_.get(i)); } @@ -1364,6 +1415,14 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeBoolSize(17, transportSecurity_); } + { + int dataSize = 0; + for (int i = 0; i < httpRouteIDs_.size(); i++) { + dataSize += computeStringSizeNoTag(httpRouteIDs_.getRaw(i)); + } + size += dataSize; + size += 2 * getHttpRouteIDsList().size(); + } for (int i = 0; i < graphqlComplexityInfo_.size(); i++) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(23, graphqlComplexityInfo_.get(i)); @@ -1448,6 +1507,8 @@ public boolean equals(final java.lang.Object obj) { other.internalGetApplicationSecurity())) return false; if (getTransportSecurity() != other.getTransportSecurity()) return false; + if (!getHttpRouteIDsList() + .equals(other.getHttpRouteIDsList())) return false; if (!getGraphqlComplexityInfoList() .equals(other.getGraphqlComplexityInfoList())) return false; if (getSystemAPI() @@ -1529,6 +1590,10 @@ public int hashCode() { hash = (37 * hash) + TRANSPORTSECURITY_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( getTransportSecurity()); + if (getHttpRouteIDsCount() > 0) { + hash = (37 * hash) + HTTPROUTEIDS_FIELD_NUMBER; + hash = (53 * hash) + getHttpRouteIDsList().hashCode(); + } if (getGraphqlComplexityInfoCount() > 0) { hash = (37 * hash) + GRAPHQLCOMPLEXITYINFO_FIELD_NUMBER; hash = (53 * hash) + getGraphqlComplexityInfoList().hashCode(); @@ -1763,9 +1828,11 @@ public Builder clear() { internalGetMutableApplicationSecurity().clear(); transportSecurity_ = false; + httpRouteIDs_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000008); if (graphqlComplexityInfoBuilder_ == null) { graphqlComplexityInfo_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000010); } else { graphqlComplexityInfoBuilder_.clear(); } @@ -1791,7 +1858,7 @@ public Builder clear() { } if (endpointSecurityBuilder_ == null) { endpointSecurity_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000020); } else { endpointSecurityBuilder_.clear(); } @@ -1862,10 +1929,15 @@ public org.wso2.apk.enforcer.discovery.api.Api buildPartial() { result.applicationSecurity_ = internalGetApplicationSecurity(); result.applicationSecurity_.makeImmutable(); result.transportSecurity_ = transportSecurity_; + if (((bitField0_ & 0x00000008) != 0)) { + httpRouteIDs_ = httpRouteIDs_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.httpRouteIDs_ = httpRouteIDs_; if (graphqlComplexityInfoBuilder_ == null) { - if (((bitField0_ & 0x00000008) != 0)) { + if (((bitField0_ & 0x00000010) != 0)) { graphqlComplexityInfo_ = java.util.Collections.unmodifiableList(graphqlComplexityInfo_); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000010); } result.graphqlComplexityInfo_ = graphqlComplexityInfo_; } else { @@ -1886,9 +1958,9 @@ public org.wso2.apk.enforcer.discovery.api.Api buildPartial() { result.endpoints_ = endpointsBuilder_.build(); } if (endpointSecurityBuilder_ == null) { - if (((bitField0_ & 0x00000010) != 0)) { + if (((bitField0_ & 0x00000020) != 0)) { endpointSecurity_ = java.util.Collections.unmodifiableList(endpointSecurity_); - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000020); } result.endpointSecurity_ = endpointSecurity_; } else { @@ -2054,11 +2126,21 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.api.Api other) { if (other.getTransportSecurity() != false) { setTransportSecurity(other.getTransportSecurity()); } + if (!other.httpRouteIDs_.isEmpty()) { + if (httpRouteIDs_.isEmpty()) { + httpRouteIDs_ = other.httpRouteIDs_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureHttpRouteIDsIsMutable(); + httpRouteIDs_.addAll(other.httpRouteIDs_); + } + onChanged(); + } if (graphqlComplexityInfoBuilder_ == null) { if (!other.graphqlComplexityInfo_.isEmpty()) { if (graphqlComplexityInfo_.isEmpty()) { graphqlComplexityInfo_ = other.graphqlComplexityInfo_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000010); } else { ensureGraphqlComplexityInfoIsMutable(); graphqlComplexityInfo_.addAll(other.graphqlComplexityInfo_); @@ -2071,7 +2153,7 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.api.Api other) { graphqlComplexityInfoBuilder_.dispose(); graphqlComplexityInfoBuilder_ = null; graphqlComplexityInfo_ = other.graphqlComplexityInfo_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000010); graphqlComplexityInfoBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getGraphqlComplexityInfoFieldBuilder() : null; @@ -2103,7 +2185,7 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.api.Api other) { if (!other.endpointSecurity_.isEmpty()) { if (endpointSecurity_.isEmpty()) { endpointSecurity_ = other.endpointSecurity_; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000020); } else { ensureEndpointSecurityIsMutable(); endpointSecurity_.addAll(other.endpointSecurity_); @@ -2116,7 +2198,7 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.api.Api other) { endpointSecurityBuilder_.dispose(); endpointSecurityBuilder_ = null; endpointSecurity_ = other.endpointSecurity_; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000020); endpointSecurityBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getEndpointSecurityFieldBuilder() : null; @@ -3767,12 +3849,122 @@ public Builder clearTransportSecurity() { return this; } + private com.google.protobuf.LazyStringList httpRouteIDs_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureHttpRouteIDsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + httpRouteIDs_ = new com.google.protobuf.LazyStringArrayList(httpRouteIDs_); + bitField0_ |= 0x00000008; + } + } + /** + * repeated string httpRouteIDs = 19; + * @return A list containing the httpRouteIDs. + */ + public com.google.protobuf.ProtocolStringList + getHttpRouteIDsList() { + return httpRouteIDs_.getUnmodifiableView(); + } + /** + * repeated string httpRouteIDs = 19; + * @return The count of httpRouteIDs. + */ + public int getHttpRouteIDsCount() { + return httpRouteIDs_.size(); + } + /** + * repeated string httpRouteIDs = 19; + * @param index The index of the element to return. + * @return The httpRouteIDs at the given index. + */ + public java.lang.String getHttpRouteIDs(int index) { + return httpRouteIDs_.get(index); + } + /** + * repeated string httpRouteIDs = 19; + * @param index The index of the value to return. + * @return The bytes of the httpRouteIDs at the given index. + */ + public com.google.protobuf.ByteString + getHttpRouteIDsBytes(int index) { + return httpRouteIDs_.getByteString(index); + } + /** + * repeated string httpRouteIDs = 19; + * @param index The index to set the value at. + * @param value The httpRouteIDs to set. + * @return This builder for chaining. + */ + public Builder setHttpRouteIDs( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureHttpRouteIDsIsMutable(); + httpRouteIDs_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string httpRouteIDs = 19; + * @param value The httpRouteIDs to add. + * @return This builder for chaining. + */ + public Builder addHttpRouteIDs( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureHttpRouteIDsIsMutable(); + httpRouteIDs_.add(value); + onChanged(); + return this; + } + /** + * repeated string httpRouteIDs = 19; + * @param values The httpRouteIDs to add. + * @return This builder for chaining. + */ + public Builder addAllHttpRouteIDs( + java.lang.Iterable values) { + ensureHttpRouteIDsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, httpRouteIDs_); + onChanged(); + return this; + } + /** + * repeated string httpRouteIDs = 19; + * @return This builder for chaining. + */ + public Builder clearHttpRouteIDs() { + httpRouteIDs_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + /** + * repeated string httpRouteIDs = 19; + * @param value The bytes of the httpRouteIDs to add. + * @return This builder for chaining. + */ + public Builder addHttpRouteIDsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureHttpRouteIDsIsMutable(); + httpRouteIDs_.add(value); + onChanged(); + return this; + } + private java.util.List graphqlComplexityInfo_ = java.util.Collections.emptyList(); private void ensureGraphqlComplexityInfoIsMutable() { - if (!((bitField0_ & 0x00000008) != 0)) { + if (!((bitField0_ & 0x00000010) != 0)) { graphqlComplexityInfo_ = new java.util.ArrayList(graphqlComplexityInfo_); - bitField0_ |= 0x00000008; + bitField0_ |= 0x00000010; } } @@ -3966,7 +4158,7 @@ public Builder addAllGraphqlComplexityInfo( public Builder clearGraphqlComplexityInfo() { if (graphqlComplexityInfoBuilder_ == null) { graphqlComplexityInfo_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000010); onChanged(); } else { graphqlComplexityInfoBuilder_.clear(); @@ -4071,7 +4263,7 @@ public org.wso2.apk.enforcer.discovery.api.GraphqlComplexity.Builder addGraphqlC graphqlComplexityInfoBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< org.wso2.apk.enforcer.discovery.api.GraphqlComplexity, org.wso2.apk.enforcer.discovery.api.GraphqlComplexity.Builder, org.wso2.apk.enforcer.discovery.api.GraphqlComplexityOrBuilder>( graphqlComplexityInfo_, - ((bitField0_ & 0x00000008) != 0), + ((bitField0_ & 0x00000010) != 0), getParentForChildren(), isClean()); graphqlComplexityInfo_ = null; @@ -4492,9 +4684,9 @@ public org.wso2.apk.enforcer.discovery.api.EndpointClusterOrBuilder getEndpoints private java.util.List endpointSecurity_ = java.util.Collections.emptyList(); private void ensureEndpointSecurityIsMutable() { - if (!((bitField0_ & 0x00000010) != 0)) { + if (!((bitField0_ & 0x00000020) != 0)) { endpointSecurity_ = new java.util.ArrayList(endpointSecurity_); - bitField0_ |= 0x00000010; + bitField0_ |= 0x00000020; } } @@ -4644,7 +4836,7 @@ public Builder addAllEndpointSecurity( public Builder clearEndpointSecurity() { if (endpointSecurityBuilder_ == null) { endpointSecurity_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000020); onChanged(); } else { endpointSecurityBuilder_.clear(); @@ -4721,7 +4913,7 @@ public org.wso2.apk.enforcer.discovery.api.SecurityInfo.Builder addEndpointSecur endpointSecurityBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< org.wso2.apk.enforcer.discovery.api.SecurityInfo, org.wso2.apk.enforcer.discovery.api.SecurityInfo.Builder, org.wso2.apk.enforcer.discovery.api.SecurityInfoOrBuilder>( endpointSecurity_, - ((bitField0_ & 0x00000010) != 0), + ((bitField0_ & 0x00000020) != 0), getParentForChildren(), isClean()); endpointSecurity_ = null; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiOrBuilder.java index 437851660..6b1e2770d 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiOrBuilder.java @@ -259,6 +259,31 @@ boolean getApplicationSecurityOrThrow( */ boolean getTransportSecurity(); + /** + * repeated string httpRouteIDs = 19; + * @return A list containing the httpRouteIDs. + */ + java.util.List + getHttpRouteIDsList(); + /** + * repeated string httpRouteIDs = 19; + * @return The count of httpRouteIDs. + */ + int getHttpRouteIDsCount(); + /** + * repeated string httpRouteIDs = 19; + * @param index The index of the element to return. + * @return The httpRouteIDs at the given index. + */ + java.lang.String getHttpRouteIDs(int index); + /** + * repeated string httpRouteIDs = 19; + * @param index The index of the value to return. + * @return The bytes of the httpRouteIDs at the given index. + */ + com.google.protobuf.ByteString + getHttpRouteIDsBytes(int index); + /** *
    */ string graphQLSchema = 22;
diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java
index 8f168c4d2..0a4e79198 100644
--- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java
+++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java
@@ -41,7 +41,7 @@ public static void registerAllExtensions(
       "luster.proto\032&wso2/discovery/api/securit" +
       "y_info.proto\032 wso2/discovery/api/graphql" +
       ".proto\032$wso2/discovery/api/ai_provider.p" +
-      "roto\"\252\007\n\003Api\022\n\n\002id\030\001 \001(\t\022\r\n\005title\030\002 \001(\t\022" +
+      "roto\"\300\007\n\003Api\022\n\n\002id\030\001 \001(\t\022\r\n\005title\030\002 \001(\t\022" +
       "\017\n\007version\030\003 \001(\t\022\017\n\007apiType\030\004 \001(\t\022\036\n\026dis" +
       "ableAuthentications\030\005 \001(\010\022\025\n\rdisableScop" +
       "es\030\006 \001(\010\022\017\n\007envType\030\007 \001(\t\022/\n\tresources\030\010" +
@@ -52,22 +52,23 @@ public static void registerAllExtensions(
       "2\037.wso2.discovery.api.Certificate\022\021\n\tmut" +
       "ualSSL\030\017 \001(\t\022M\n\023applicationSecurity\030\020 \003(" +
       "\01320.wso2.discovery.api.Api.ApplicationSe" +
-      "curityEntry\022\031\n\021transportSecurity\030\021 \001(\010\022D" +
-      "\n\025graphqlComplexityInfo\030\027 \003(\0132%.wso2.dis" +
-      "covery.api.GraphqlComplexity\022\021\n\tsystemAP" +
-      "I\030\030 \001(\010\022D\n\023backendJWTTokenInfo\030\031 \001(\0132\'.w" +
-      "so2.discovery.api.BackendJWTTokenInfo\022\031\n" +
-      "\021apiDefinitionFile\030\032 \001(\014\022\023\n\013environment\030" +
-      "\033 \001(\t\022\036\n\026subscriptionValidation\030\034 \001(\010\0226\n" +
-      "\tendpoints\030\035 \001(\0132#.wso2.discovery.api.En" +
-      "dpointCluster\022:\n\020endpointSecurity\030\036 \003(\0132" +
-      " .wso2.discovery.api.SecurityInfo\0222\n\naip" +
-      "rovider\030\037 \001(\0132\036.wso2.discovery.api.AIPro" +
-      "vider\032:\n\030ApplicationSecurityEntry\022\013\n\003key" +
-      "\030\001 \001(\t\022\r\n\005value\030\002 \001(\010:\0028\001Bp\n#org.wso2.ap" +
-      "k.enforcer.discovery.apiB\010ApiProtoP\001Z=gi" +
-      "thub.com/envoyproxy/go-control-plane/wso" +
-      "2/discovery/api;apib\006proto3"
+      "curityEntry\022\031\n\021transportSecurity\030\021 \001(\010\022\024" +
+      "\n\014httpRouteIDs\030\023 \003(\t\022D\n\025graphqlComplexit" +
+      "yInfo\030\027 \003(\0132%.wso2.discovery.api.Graphql" +
+      "Complexity\022\021\n\tsystemAPI\030\030 \001(\010\022D\n\023backend" +
+      "JWTTokenInfo\030\031 \001(\0132\'.wso2.discovery.api." +
+      "BackendJWTTokenInfo\022\031\n\021apiDefinitionFile" +
+      "\030\032 \001(\014\022\023\n\013environment\030\033 \001(\t\022\036\n\026subscript" +
+      "ionValidation\030\034 \001(\010\0226\n\tendpoints\030\035 \001(\0132#" +
+      ".wso2.discovery.api.EndpointCluster\022:\n\020e" +
+      "ndpointSecurity\030\036 \003(\0132 .wso2.discovery.a" +
+      "pi.SecurityInfo\0222\n\naiprovider\030\037 \001(\0132\036.ws" +
+      "o2.discovery.api.AIProvider\032:\n\030Applicati" +
+      "onSecurityEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 " +
+      "\001(\010:\0028\001Bp\n#org.wso2.apk.enforcer.discove" +
+      "ry.apiB\010ApiProtoP\001Z=github.com/envoyprox" +
+      "y/go-control-plane/wso2/discovery/api;ap" +
+      "ib\006proto3"
     };
     descriptor = com.google.protobuf.Descriptors.FileDescriptor
       .internalBuildGeneratedFileFrom(descriptorData,
@@ -85,7 +86,7 @@ public static void registerAllExtensions(
     internal_static_wso2_discovery_api_Api_fieldAccessorTable = new
       com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
         internal_static_wso2_discovery_api_Api_descriptor,
-        new java.lang.String[] { "Id", "Title", "Version", "ApiType", "DisableAuthentications", "DisableScopes", "EnvType", "Resources", "BasePath", "Tier", "ApiLifeCycleState", "Vhost", "OrganizationId", "ClientCertificates", "MutualSSL", "ApplicationSecurity", "TransportSecurity", "GraphqlComplexityInfo", "SystemAPI", "BackendJWTTokenInfo", "ApiDefinitionFile", "Environment", "SubscriptionValidation", "Endpoints", "EndpointSecurity", "Aiprovider", });
+        new java.lang.String[] { "Id", "Title", "Version", "ApiType", "DisableAuthentications", "DisableScopes", "EnvType", "Resources", "BasePath", "Tier", "ApiLifeCycleState", "Vhost", "OrganizationId", "ClientCertificates", "MutualSSL", "ApplicationSecurity", "TransportSecurity", "HttpRouteIDs", "GraphqlComplexityInfo", "SystemAPI", "BackendJWTTokenInfo", "ApiDefinitionFile", "Environment", "SubscriptionValidation", "Endpoints", "EndpointSecurity", "Aiprovider", });
     internal_static_wso2_discovery_api_Api_ApplicationSecurityEntry_descriptor =
       internal_static_wso2_discovery_api_Api_descriptor.getNestedTypes().get(0);
     internal_static_wso2_discovery_api_Api_ApplicationSecurityEntry_fieldAccessorTable = new
diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Operation.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Operation.java
index c1d341c12..b6a529edb 100644
--- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Operation.java
+++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Operation.java
@@ -23,6 +23,7 @@ private Operation() {
     method_ = "";
     tier_ = "";
     scopes_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+    matchID_ = "";
   }
 
   @java.lang.Override
@@ -103,6 +104,12 @@ private Operation(
             scopes_.add(s);
             break;
           }
+          case 50: {
+            java.lang.String s = input.readStringRequireUtf8();
+
+            matchID_ = s;
+            break;
+          }
           default: {
             if (!parseUnknownField(
                 input, unknownFields, extensionRegistry, tag)) {
@@ -269,10 +276,6 @@ public org.wso2.apk.enforcer.discovery.api.OperationPoliciesOrBuilder getPolicie
   public static final int SCOPES_FIELD_NUMBER = 5;
   private com.google.protobuf.LazyStringList scopes_;
   /**
-   * 
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @return A list containing the scopes. */ @@ -281,10 +284,6 @@ public org.wso2.apk.enforcer.discovery.api.OperationPoliciesOrBuilder getPolicie return scopes_; } /** - *
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @return The count of scopes. */ @@ -292,10 +291,6 @@ public int getScopesCount() { return scopes_.size(); } /** - *
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @param index The index of the element to return. * @return The scopes at the given index. @@ -304,10 +299,6 @@ public java.lang.String getScopes(int index) { return scopes_.get(index); } /** - *
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @param index The index of the value to return. * @return The bytes of the scopes at the given index. @@ -317,6 +308,52 @@ public java.lang.String getScopes(int index) { return scopes_.getByteString(index); } + public static final int MATCHID_FIELD_NUMBER = 6; + private volatile java.lang.Object matchID_; + /** + *
+   * MockedApiConfig mockedApiConfig = 6;
+   * 
+ * + * string matchID = 6; + * @return The matchID. + */ + @java.lang.Override + public java.lang.String getMatchID() { + java.lang.Object ref = matchID_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + matchID_ = s; + return s; + } + } + /** + *
+   * MockedApiConfig mockedApiConfig = 6;
+   * 
+ * + * string matchID = 6; + * @return The bytes for matchID. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getMatchIDBytes() { + java.lang.Object ref = matchID_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + matchID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -346,6 +383,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < scopes_.size(); i++) { com.google.protobuf.GeneratedMessageV3.writeString(output, 5, scopes_.getRaw(i)); } + if (!getMatchIDBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, matchID_); + } unknownFields.writeTo(output); } @@ -377,6 +417,9 @@ public int getSerializedSize() { size += dataSize; size += 1 * getScopesList().size(); } + if (!getMatchIDBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, matchID_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -408,6 +451,8 @@ public boolean equals(final java.lang.Object obj) { } if (!getScopesList() .equals(other.getScopesList())) return false; + if (!getMatchID() + .equals(other.getMatchID())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -435,6 +480,8 @@ public int hashCode() { hash = (37 * hash) + SCOPES_FIELD_NUMBER; hash = (53 * hash) + getScopesList().hashCode(); } + hash = (37 * hash) + MATCHID_FIELD_NUMBER; + hash = (53 * hash) + getMatchID().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -590,6 +637,8 @@ public Builder clear() { } scopes_ = com.google.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000001); + matchID_ = ""; + return this; } @@ -634,6 +683,7 @@ public org.wso2.apk.enforcer.discovery.api.Operation buildPartial() { bitField0_ = (bitField0_ & ~0x00000001); } result.scopes_ = scopes_; + result.matchID_ = matchID_; onBuilt(); return result; } @@ -706,6 +756,10 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.api.Operation other) { } onChanged(); } + if (!other.getMatchID().isEmpty()) { + matchID_ = other.matchID_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1134,10 +1188,6 @@ private void ensureScopesIsMutable() { } } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @return A list containing the scopes. */ @@ -1146,10 +1196,6 @@ private void ensureScopesIsMutable() { return scopes_.getUnmodifiableView(); } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @return The count of scopes. */ @@ -1157,10 +1203,6 @@ public int getScopesCount() { return scopes_.size(); } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @param index The index of the element to return. * @return The scopes at the given index. @@ -1169,10 +1211,6 @@ public java.lang.String getScopes(int index) { return scopes_.get(index); } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @param index The index of the value to return. * @return The bytes of the scopes at the given index. @@ -1182,10 +1220,6 @@ public java.lang.String getScopes(int index) { return scopes_.getByteString(index); } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @param index The index to set the value at. * @param value The scopes to set. @@ -1202,10 +1236,6 @@ public Builder setScopes( return this; } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @param value The scopes to add. * @return This builder for chaining. @@ -1221,10 +1251,6 @@ public Builder addScopes( return this; } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @param values The scopes to add. * @return This builder for chaining. @@ -1238,10 +1264,6 @@ public Builder addAllScopes( return this; } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @return This builder for chaining. */ @@ -1252,10 +1274,6 @@ public Builder clearScopes() { return this; } /** - *
-     * MockedApiConfig mockedApiConfig = 6;
-     * 
- * * repeated string scopes = 5; * @param value The bytes of the scopes to add. * @return This builder for chaining. @@ -1271,6 +1289,102 @@ public Builder addScopesBytes( onChanged(); return this; } + + private java.lang.Object matchID_ = ""; + /** + *
+     * MockedApiConfig mockedApiConfig = 6;
+     * 
+ * + * string matchID = 6; + * @return The matchID. + */ + public java.lang.String getMatchID() { + java.lang.Object ref = matchID_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + matchID_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * MockedApiConfig mockedApiConfig = 6;
+     * 
+ * + * string matchID = 6; + * @return The bytes for matchID. + */ + public com.google.protobuf.ByteString + getMatchIDBytes() { + java.lang.Object ref = matchID_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + matchID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * MockedApiConfig mockedApiConfig = 6;
+     * 
+ * + * string matchID = 6; + * @param value The matchID to set. + * @return This builder for chaining. + */ + public Builder setMatchID( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + matchID_ = value; + onChanged(); + return this; + } + /** + *
+     * MockedApiConfig mockedApiConfig = 6;
+     * 
+ * + * string matchID = 6; + * @return This builder for chaining. + */ + public Builder clearMatchID() { + + matchID_ = getDefaultInstance().getMatchID(); + onChanged(); + return this; + } + /** + *
+     * MockedApiConfig mockedApiConfig = 6;
+     * 
+ * + * string matchID = 6; + * @param value The bytes for matchID to set. + * @return This builder for chaining. + */ + public Builder setMatchIDBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + matchID_ = value; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/OperationOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/OperationOrBuilder.java index 5eb178d36..c8185fa4a 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/OperationOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/OperationOrBuilder.java @@ -62,43 +62,47 @@ public interface OperationOrBuilder extends org.wso2.apk.enforcer.discovery.api.OperationPoliciesOrBuilder getPoliciesOrBuilder(); /** - *
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @return A list containing the scopes. */ java.util.List getScopesList(); /** - *
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @return The count of scopes. */ int getScopesCount(); /** - *
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @param index The index of the element to return. * @return The scopes at the given index. */ java.lang.String getScopes(int index); /** - *
-   * MockedApiConfig mockedApiConfig = 6;
-   * 
- * * repeated string scopes = 5; * @param index The index of the value to return. * @return The bytes of the scopes at the given index. */ com.google.protobuf.ByteString getScopesBytes(int index); + + /** + *
+   * MockedApiConfig mockedApiConfig = 6;
+   * 
+ * + * string matchID = 6; + * @return The matchID. + */ + java.lang.String getMatchID(); + /** + *
+   * MockedApiConfig mockedApiConfig = 6;
+   * 
+ * + * string matchID = 6; + * @return The bytes for matchID. + */ + com.google.protobuf.ByteString + getMatchIDBytes(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ResourceProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ResourceProto.java index a8f5f727b..3b26d4fcc 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ResourceProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ResourceProto.java @@ -57,22 +57,23 @@ public static void registerAllExtensions( "\035.wso2.discovery.api.Operation\0226\n\tendpoi" + "nts\030\004 \001(\0132#.wso2.discovery.api.EndpointC" + "luster\022:\n\020endpointSecurity\030\005 \003(\0132 .wso2." + - "discovery.api.SecurityInfo\"\264\001\n\tOperation" + + "discovery.api.SecurityInfo\"\305\001\n\tOperation" + "\022\016\n\006method\030\001 \001(\t\022@\n\021apiAuthentication\030\002 " + "\001(\0132%.wso2.discovery.api.APIAuthenticati" + "on\022\014\n\004tier\030\003 \001(\t\0227\n\010policies\030\004 \001(\0132%.wso" + "2.discovery.api.OperationPolicies\022\016\n\006sco" + - "pes\030\005 \003(\t\"\231\001\n\021OperationPolicies\022+\n\007reque" + - "st\030\001 \003(\0132\032.wso2.discovery.api.Policy\022,\n\010" + - "response\030\002 \003(\0132\032.wso2.discovery.api.Poli" + - "cy\022)\n\005fault\030\003 \003(\0132\032.wso2.discovery.api.P" + - "olicy\"\213\001\n\006Policy\022\016\n\006action\030\001 \001(\t\022>\n\npara" + - "meters\030\002 \003(\0132*.wso2.discovery.api.Policy" + - ".ParametersEntry\0321\n\017ParametersEntry\022\013\n\003k" + - "ey\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001Bu\n#org.wso2." + - "apk.enforcer.discovery.apiB\rResourceProt" + - "oP\001Z=github.com/envoyproxy/go-control-pl" + - "ane/wso2/discovery/api;apib\006proto3" + "pes\030\005 \003(\t\022\017\n\007matchID\030\006 \001(\t\"\231\001\n\021Operation" + + "Policies\022+\n\007request\030\001 \003(\0132\032.wso2.discove" + + "ry.api.Policy\022,\n\010response\030\002 \003(\0132\032.wso2.d" + + "iscovery.api.Policy\022)\n\005fault\030\003 \003(\0132\032.wso" + + "2.discovery.api.Policy\"\213\001\n\006Policy\022\016\n\006act" + + "ion\030\001 \001(\t\022>\n\nparameters\030\002 \003(\0132*.wso2.dis" + + "covery.api.Policy.ParametersEntry\0321\n\017Par" + + "ametersEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t" + + ":\0028\001Bu\n#org.wso2.apk.enforcer.discovery." + + "apiB\rResourceProtoP\001Z=github.com/envoypr" + + "oxy/go-control-plane/wso2/discovery/api;" + + "apib\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -92,7 +93,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_api_Operation_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_api_Operation_descriptor, - new java.lang.String[] { "Method", "ApiAuthentication", "Tier", "Policies", "Scopes", }); + new java.lang.String[] { "Method", "ApiAuthentication", "Tier", "Policies", "Scopes", "MatchID", }); internal_static_wso2_discovery_api_OperationPolicies_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_wso2_discovery_api_OperationPolicies_fieldAccessorTable = new diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Config.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Config.java index e6d37cb50..3a427d967 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Config.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Config.java @@ -229,6 +229,11 @@ private Config( mandateInternalKeyValidation_ = input.readBool(); break; } + case 128: { + + enableGatewayClassController_ = input.readBool(); + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -638,6 +643,17 @@ public boolean getMandateInternalKeyValidation() { return mandateInternalKeyValidation_; } + public static final int ENABLEGATEWAYCLASSCONTROLLER_FIELD_NUMBER = 16; + private boolean enableGatewayClassController_; + /** + * bool enableGatewayClassController = 16; + * @return The enableGatewayClassController. + */ + @java.lang.Override + public boolean getEnableGatewayClassController() { + return enableGatewayClassController_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -697,6 +713,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (mandateInternalKeyValidation_ != false) { output.writeBool(15, mandateInternalKeyValidation_); } + if (enableGatewayClassController_ != false) { + output.writeBool(16, enableGatewayClassController_); + } unknownFields.writeTo(output); } @@ -766,6 +785,10 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeBoolSize(15, mandateInternalKeyValidation_); } + if (enableGatewayClassController_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(16, enableGatewayClassController_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -847,6 +870,8 @@ public boolean equals(final java.lang.Object obj) { } if (getMandateInternalKeyValidation() != other.getMandateInternalKeyValidation()) return false; + if (getEnableGatewayClassController() + != other.getEnableGatewayClassController()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -916,6 +941,9 @@ public int hashCode() { hash = (37 * hash) + MANDATEINTERNALKEYVALIDATION_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( getMandateInternalKeyValidation()); + hash = (37 * hash) + ENABLEGATEWAYCLASSCONTROLLER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableGatewayClassController()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1136,6 +1164,8 @@ public Builder clear() { } mandateInternalKeyValidation_ = false; + enableGatewayClassController_ = false; + return this; } @@ -1234,6 +1264,7 @@ public org.wso2.apk.enforcer.discovery.config.enforcer.Config buildPartial() { result.httpClient_ = httpClientBuilder_.build(); } result.mandateInternalKeyValidation_ = mandateInternalKeyValidation_; + result.enableGatewayClassController_ = enableGatewayClassController_; onBuilt(); return result; } @@ -1350,6 +1381,9 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.config.enforcer.Config if (other.getMandateInternalKeyValidation() != false) { setMandateInternalKeyValidation(other.getMandateInternalKeyValidation()); } + if (other.getEnableGatewayClassController() != false) { + setEnableGatewayClassController(other.getEnableGatewayClassController()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -3109,6 +3143,37 @@ public Builder clearMandateInternalKeyValidation() { onChanged(); return this; } + + private boolean enableGatewayClassController_ ; + /** + * bool enableGatewayClassController = 16; + * @return The enableGatewayClassController. + */ + @java.lang.Override + public boolean getEnableGatewayClassController() { + return enableGatewayClassController_; + } + /** + * bool enableGatewayClassController = 16; + * @param value The enableGatewayClassController to set. + * @return This builder for chaining. + */ + public Builder setEnableGatewayClassController(boolean value) { + + enableGatewayClassController_ = value; + onChanged(); + return this; + } + /** + * bool enableGatewayClassController = 16; + * @return This builder for chaining. + */ + public Builder clearEnableGatewayClassController() { + + enableGatewayClassController_ = false; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigOrBuilder.java index 9bb944b65..78cc44cf3 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigOrBuilder.java @@ -222,4 +222,10 @@ org.wso2.apk.enforcer.discovery.config.enforcer.FilterOrBuilder getFiltersOrBuil * @return The mandateInternalKeyValidation. */ boolean getMandateInternalKeyValidation(); + + /** + * bool enableGatewayClassController = 16; + * @return The enableGatewayClassController. + */ + boolean getEnableGatewayClassController(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigProto.java index 1142d75aa..23291675f 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/ConfigProto.java @@ -43,7 +43,7 @@ public static void registerAllExtensions( "cer/tracing.proto\032,wso2/discovery/config" + "/enforcer/metrics.proto\032)wso2/discovery/" + "config/enforcer/soap.proto\032+wso2/discove" + - "ry/config/enforcer/client.proto\"\344\006\n\006Conf" + + "ry/config/enforcer/client.proto\"\212\007\n\006Conf" + "ig\022:\n\010security\030\001 \001(\0132(.wso2.discovery.co" + "nfig.enforcer.Security\022;\n\010keystore\030\002 \001(\013" + "2).wso2.discovery.config.enforcer.CertSt" + @@ -65,11 +65,12 @@ public static void registerAllExtensions( "p\022%\n\035mandateSubscriptionValidation\030\r \001(\010" + "\022>\n\nhttpClient\030\016 \001(\0132*.wso2.discovery.co" + "nfig.enforcer.HttpClient\022$\n\034mandateInter" + - "nalKeyValidation\030\017 \001(\010B\220\001\n/org.wso2.apk." + - "enforcer.discovery.config.enforcerB\013Conf" + - "igProtoP\001ZNgithub.com/envoyproxy/go-cont" + - "rol-plane/wso2/discovery/config/enforcer" + - ";enforcerb\006proto3" + "nalKeyValidation\030\017 \001(\010\022$\n\034enableGatewayC" + + "lassController\030\020 \001(\010B\220\001\n/org.wso2.apk.en" + + "forcer.discovery.config.enforcerB\013Config" + + "ProtoP\001ZNgithub.com/envoyproxy/go-contro" + + "l-plane/wso2/discovery/config/enforcer;e" + + "nforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -92,7 +93,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_Config_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_Config_descriptor, - new java.lang.String[] { "Security", "Keystore", "Truststore", "AuthService", "JwtGenerator", "Cache", "Analytics", "Management", "Tracing", "Metrics", "Filters", "Soap", "MandateSubscriptionValidation", "HttpClient", "MandateInternalKeyValidation", }); + new java.lang.String[] { "Security", "Keystore", "Truststore", "AuthService", "JwtGenerator", "Cache", "Analytics", "Management", "Tracing", "Metrics", "Filters", "Soap", "MandateSubscriptionValidation", "HttpClient", "MandateInternalKeyValidation", "EnableGatewayClassController", }); org.wso2.apk.enforcer.discovery.config.enforcer.CertStoreProto.getDescriptor(); org.wso2.apk.enforcer.discovery.config.enforcer.ServiceProto.getDescriptor(); org.wso2.apk.enforcer.discovery.config.enforcer.JWTGeneratorProto.getDescriptor(); diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/graphql/GraphQLPayloadUtils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/graphql/GraphQLPayloadUtils.java index 2bd2147f1..b0140b904 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/graphql/GraphQLPayloadUtils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/graphql/GraphQLPayloadUtils.java @@ -32,6 +32,8 @@ import org.wso2.apk.enforcer.commons.constants.GraphQLConstants; import org.wso2.apk.enforcer.commons.graphql.GraphQLProcessorUtil; import org.wso2.apk.enforcer.commons.graphql.QueryValidator; +import org.wso2.apk.enforcer.config.ConfigHolder; +import org.wso2.apk.enforcer.config.EnforcerConfig; import org.wso2.apk.enforcer.discovery.api.GraphqlComplexity; import org.wso2.apk.enforcer.api.API; import org.wso2.apk.enforcer.api.APIFactory; @@ -62,7 +64,7 @@ public class GraphQLPayloadUtils { * @return matching resource configs for the request * @throws EnforcerException use for error response handling */ - public static ArrayList buildGQLRequestContext(API api, String queryBody) throws EnforcerException { + public static ArrayList buildGQLRequestContext(API api, String queryBody, String routeName) throws EnforcerException { GraphQLSchemaDTO graphQLSchemaDTO = api.getAPIConfig().getGraphQLSchemaDTO(); try { // Validate payload with graphQLSchema @@ -89,7 +91,14 @@ public static ArrayList buildGQLRequestContext(API api, String q } ArrayList resourceConfigs = new ArrayList<>(); for (String op : operationList) { - ResourceConfig resourceConfig = APIFactory.getInstance().getMatchedResource(api, op, method); + EnforcerConfig enforcerConfig = ConfigHolder.getInstance().getConfig(); + ResourceConfig resourceConfig; + if (enforcerConfig.getEnableGatewayClassController()) { + resourceConfig = APIFactory.getInstance().getMatchedResource(api, routeName); + } else { + resourceConfig = APIFactory.getInstance().getMatchedResource(api, op, method); + } + if (resourceConfig != null) { resourceConfigs.add(resourceConfig); } else { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/server/HttpRequestHandler.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/server/HttpRequestHandler.java index 97d232374..7a65c2f4f 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/server/HttpRequestHandler.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/server/HttpRequestHandler.java @@ -32,6 +32,8 @@ import org.wso2.apk.enforcer.commons.model.APIConfig; import org.wso2.apk.enforcer.commons.model.RequestContext; import org.wso2.apk.enforcer.commons.model.ResourceConfig; +import org.wso2.apk.enforcer.config.ConfigHolder; +import org.wso2.apk.enforcer.config.EnforcerConfig; import org.wso2.apk.enforcer.constants.APIConstants; import org.wso2.apk.enforcer.constants.AdapterConstants; import org.wso2.apk.enforcer.constants.HttpConstants; @@ -87,6 +89,7 @@ private RequestContext buildRequestContext(API api, CheckRequest request) { String certificate = request.getAttributes().getSource().getCertificate(); Map headers = request.getAttributes().getRequest().getHttp().getHeadersMap(); String pathTemplate = request.getAttributes().getContextExtensionsMap().get(APIConstants.GW_RES_PATH_PARAM); + String routeName = request.getAttributes().getContextExtensionsMap().get(APIConstants.ROUTE_NAME_PARAM); String cluster = request.getAttributes().getContextExtensionsMap() .get(AdapterConstants.CLUSTER_HEADER_KEY); long requestTimeInMillis = request.getAttributes().getRequest().getTime().getSeconds() * 1000 + @@ -116,11 +119,12 @@ private RequestContext buildRequestContext(API api, CheckRequest request) { ResourceConfig resourceConfig = null; ArrayList resourceConfigs = null; boolean isGraphQLAPI = api.getAPIConfig().getApiType().equals(APIConstants.ApiType.GRAPHQL); + EnforcerConfig enforcerConfig = ConfigHolder.getInstance().getConfig(); if (isGraphQLAPI && !HttpConstants.OPTIONS.equals(method)) { // need to decode the payload if request is graphql and a non option call. try { requestPayload = GraphQLPayloadUtils.getGQLRequestPayload(requestPayload, headers); - resourceConfigs = GraphQLPayloadUtils.buildGQLRequestContext(api, requestPayload); + resourceConfigs = GraphQLPayloadUtils.buildGQLRequestContext(api, requestPayload, routeName); } catch (EnforcerException exception) { logger.error("Error while processing the graphql api request for {}", api.getAPIConfig().getName(), @@ -139,12 +143,19 @@ private RequestContext buildRequestContext(API api, CheckRequest request) { exception.getMessage()); return requestContext; } - } else if (!isGraphQLAPI) { + } else if (!isGraphQLAPI && !enforcerConfig.getEnableGatewayClassController()) { resourceConfig = APIFactory.getInstance().getMatchedResource(api, pathTemplate, method); if (resourceConfig != null) { resourceConfigs = new ArrayList<>(); resourceConfigs.add(resourceConfig); } + } else if (!isGraphQLAPI && enforcerConfig.getEnableGatewayClassController()) { + resourceConfig = APIFactory.getInstance().getMatchedResource(api, + request.getAttributes().getContextExtensionsMap().get(APIConstants.ROUTE_NAME_PARAM)); + if (resourceConfig != null) { + resourceConfigs = new ArrayList<>(); + resourceConfigs.add(resourceConfig); + } } return new RequestContext.Builder(requestPath).matchedResourceConfigs(resourceConfigs).requestMethod(method) .certificate(certificate).matchedAPI(api.getAPIConfig()).headers(headers).requestID(requestID) diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/EndpointUtils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/EndpointUtils.java index 6c3812abe..975215ce5 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/EndpointUtils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/EndpointUtils.java @@ -24,6 +24,8 @@ import org.wso2.apk.enforcer.commons.model.RequestContext; import org.wso2.apk.enforcer.commons.model.ResourceConfig; import org.wso2.apk.enforcer.commons.model.RetryConfig; +import org.wso2.apk.enforcer.config.ConfigHolder; +import org.wso2.apk.enforcer.config.EnforcerConfig; import org.wso2.apk.enforcer.constants.APIConstants; import java.util.Base64; @@ -84,7 +86,10 @@ public static void addEndpointSecurity(RequestContext requestContext) { * @param requestContext request Context */ public static void updateClusterHeaderAndCheckEnv(RequestContext requestContext) { - requestContext.addOrModifyHeaders(AdapterConstants.CLUSTER_HEADER, requestContext.getClusterHeader()); + EnforcerConfig enforcerConfig = ConfigHolder.getInstance().getConfig(); + if (!enforcerConfig.getEnableGatewayClassController()) { + requestContext.addOrModifyHeaders(AdapterConstants.CLUSTER_HEADER, requestContext.getClusterHeader()); + } requestContext.getRemoveHeaders().remove(AdapterConstants.CLUSTER_HEADER); addRouterHttpHeaders(requestContext); addEndpointSecurity(requestContext);