Skip to content

Commit

Permalink
Add subscription validation enable capability at gateway level
Browse files Browse the repository at this point in the history
  • Loading branch information
ashera96 authored and tharindu1st committed Nov 13, 2023
1 parent 62d624b commit 723c9b4
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 51 deletions.
2 changes: 2 additions & 0 deletions adapter/api/proto/wso2/discovery/config/enforcer/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ message Config {
repeated Filter filters = 11;

Soap soap = 12;

bool mandateSubscriptionValidation = 13;
}
1 change: 1 addition & 0 deletions adapter/config/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ var defaultConfig = &Config{
Enabled: false,
Type: "azure",
},
MandateSubscriptionValidation: false,
},
ManagementServer: managementServer{
Enabled: false,
Expand Down
19 changes: 10 additions & 9 deletions adapter/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,16 @@ type xRateLimitHeaders struct {
}

type enforcer struct {
Security security
AuthService authService
JwtGenerator jwtGenerator
Cache cache
JwtIssuer jwtIssuer
Management management
RestServer restServer
Filters []filter
Metrics metrics
Security security
AuthService authService
JwtGenerator jwtGenerator
Cache cache
JwtIssuer jwtIssuer
Management management
RestServer restServer
Filters []filter
Metrics metrics
MandateSubscriptionValidation bool
}

type consul struct {
Expand Down
16 changes: 9 additions & 7 deletions adapter/internal/discovery/xds/marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func MarshalConfig(config *config.Config) *enforcer.Config {
Enabled: config.Enforcer.Metrics.Enabled,
Type: config.Enforcer.Metrics.Type,
}
mandateSubscriptionValidation := config.Enforcer.MandateSubscriptionValidation
analytics := &enforcer.Analytics{
Enabled: config.Analytics.Enabled,
Properties: config.Analytics.Properties,
Expand Down Expand Up @@ -165,13 +166,14 @@ func MarshalConfig(config *config.Config) *enforcer.Config {
EnableOutboundCertificateHeader: config.Enforcer.Security.MutualSSL.EnableOutboundCertificateHeader,
},
},
Cache: cache,
Tracing: tracing,
Metrics: metrics,
Analytics: analytics,
Management: management,
Filters: filters,
Soap: soap,
Cache: cache,
Tracing: tracing,
Metrics: metrics,
Analytics: analytics,
Management: management,
Filters: filters,
Soap: soap,
MandateSubscriptionValidation: mandateSubscriptionValidation,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (gatewayReconciler *GatewayReconciler) getInterceptorServicesForGateway(ctx
}
}
}
return interceptorServices, nil // TODO(Ashera): Handle global subscription validation enable disable
return interceptorServices, nil
}

func (gatewayReconciler *GatewayReconciler) getResolvedBackendsMapping(ctx context.Context,
Expand Down

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

1 change: 0 additions & 1 deletion common-controller/commoncontroller/common_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func runCommonEnforcerServer(server xdsv3.Server, enforcerServer wso2_server.Ser
port uint) {
var grpcOptions []grpc.ServerOption
grpcOptions = append(grpcOptions, grpc.MaxConcurrentStreams(grpcMaxConcurrentStreams))
// TODO(Ashera): Add TLS support for Common Controller - Enforcer connection
publicKeyLocation, privateKeyLocation, truststoreLocation := utils.GetKeyLocations()
cert, err := utils.GetServerCertificate(publicKeyLocation, privateKeyLocation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void parseConfigs(Config config) {
populateCustomFilters(config.getFiltersList());
populateAPIKeyIssuer(config.getSecurity().getApiKey());
populateInternalTokenIssuer(config.getSecurity().getRuntimeToken());
populateMandateSubscriptionValidationConfig(config.getMandateSubscriptionValidation());
// resolve string variables provided as environment variables.
resolveConfigsWithEnvs(this.config);
}
Expand Down Expand Up @@ -196,6 +197,10 @@ private void populateSoapErrorResponseConfigs(Soap soap) {
config.setSoapErrorResponseConfigDto(soapErrorResponseConfigDto);
}

private void populateMandateSubscriptionValidationConfig(boolean mandateSubscriptionValidation) {
config.setMandateSubscriptionValidation(mandateSubscriptionValidation);
}

private void populateManagementCredentials(Management management) {

ManagementCredentialsDto managementCredentialsDto = new ManagementCredentialsDto();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class EnforcerConfig {
private FilterDTO[] customFilters;

private SoapErrorResponseConfigDto soapErrorResponseConfigDto;
private boolean mandateSubscriptionValidation;

public AuthServiceConfigurationDto getAuthService() {
return authService;
Expand Down Expand Up @@ -203,5 +204,13 @@ public BackendJWKSDto getBackendJWKSDto() {
public void setBackendJWKSDto(BackendJWKSDto backendJWKSDto) {
this.backendJWKSDto = backendJWKSDto;
}

public boolean getMandateSubscriptionValidation() {
return mandateSubscriptionValidation;
}

public void setMandateSubscriptionValidation(boolean mandateSubscriptionValidation) {
this.mandateSubscriptionValidation = mandateSubscriptionValidation;
}
}

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

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

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

Loading

0 comments on commit 723c9b4

Please sign in to comment.