Skip to content

Commit

Permalink
Merge pull request #1999 from tharindu1st/subscription-cr-apply
Browse files Browse the repository at this point in the history
fix subscription validation
  • Loading branch information
CrowleyRajapakse authored Feb 14, 2024
2 parents a37b7b9 + 491ffee commit a05a87d
Show file tree
Hide file tree
Showing 31 changed files with 1,940 additions and 173 deletions.
45 changes: 45 additions & 0 deletions adapter/api/proto/wso2/discovery/config/enforcer/client.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

syntax = "proto3";

package wso2.discovery.config.enforcer;

option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer";
option java_package = "org.wso2.apk.enforcer.discovery.config.enforcer";
option java_outer_classname = "HttpClientProto";
option java_multiple_files = true;

// [#protodoc-title: SSL]

// Model for enforcer management user
message HttpClient {
// Disable SSL Verification
bool skipSSl = 1;

// Hostname Verifier
string hostnameVerifier = 2;

// MaxtotalConnections
int32 maxTotalConnections = 3;
// MaxConnectionsPerRoute
int32 maxConnectionsPerRoute = 4;
// ConnectTimeout
int32 connectTimeout = 5;
// SocketTimeout
int32 socketTimeout = 6;

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "wso2/discovery/config/enforcer/filter.proto";
import "wso2/discovery/config/enforcer/tracing.proto";
import "wso2/discovery/config/enforcer/metrics.proto";
import "wso2/discovery/config/enforcer/soap.proto";

import "wso2/discovery/config/enforcer/client.proto";
option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer";
option java_package = "org.wso2.apk.enforcer.discovery.config.enforcer";
option java_outer_classname = "ConfigProto";
Expand Down Expand Up @@ -48,4 +48,6 @@ message Config {
Soap soap = 12;

bool mandateSubscriptionValidation = 13;

HttpClient httpClient = 14;
}
8 changes: 8 additions & 0 deletions adapter/config/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ var defaultConfig = &Config{
Username: "admin",
Password: "admin",
},
Client: httpClient{
SkipSSL: false,
HostnameVerifier: "BROWSER_COMPATIBLE",
MaxTotalConnectins: 100,
MaxPerHostConnectins: 10,
ConnectionTimeout: 10000,
SocketTimeout: 10000,
},
Security: security{
APIkey: apiKey{
Enabled: true,
Expand Down
8 changes: 7 additions & 1 deletion adapter/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ type enforcer struct {
Filters []filter
Metrics metrics
MandateSubscriptionValidation bool
Client httpClient
}

type consul struct {
Expand Down Expand Up @@ -411,7 +412,12 @@ type filter struct {
}

type httpClient struct {
RequestTimeOut time.Duration
SkipSSL bool
HostnameVerifier string
MaxTotalConnectins int
MaxPerHostConnectins int
ConnectionTimeout time.Duration
SocketTimeout time.Duration
}

type mutualSSL struct {
Expand Down
9 changes: 9 additions & 0 deletions adapter/internal/discovery/xds/marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ func MarshalConfig(config *config.Config) *enforcer.Config {
}
filters = append(filters, filter)
}
httpClient := &enforcer.HttpClient{
SkipSSl: config.Enforcer.Client.SkipSSL,
HostnameVerifier: config.Enforcer.Client.HostnameVerifier,
MaxTotalConnections: int32(config.Enforcer.Client.MaxTotalConnectins),
MaxConnectionsPerRoute: int32(config.Enforcer.Client.MaxPerHostConnectins),
ConnectTimeout: int32(config.Enforcer.Client.ConnectionTimeout),
SocketTimeout: int32(config.Enforcer.Client.SocketTimeout),
}

return &enforcer.Config{
JwtGenerator: &enforcer.JWTGenerator{
Expand Down Expand Up @@ -151,6 +159,7 @@ func MarshalConfig(config *config.Config) *enforcer.Config {
Filters: filters,
Soap: soap,
MandateSubscriptionValidation: mandateSubscriptionValidation,
HttpClient: httpClient,
}
}

Expand Down
215 changes: 215 additions & 0 deletions adapter/pkg/discovery/api/wso2/discovery/config/enforcer/client.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a05a87d

Please sign in to comment.