Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
slahirucd7 committed Dec 11, 2023
1 parent 90192a7 commit e860b9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion adapter/internal/oasparser/model/open_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func setResourcesOpenAPI(openAPI openapi3.Swagger) ([]*Resource, error) {
if openAPI.Paths != nil {
conf, _ := config.ReadConfigs()
for path, pathItem := range openAPI.Paths {
if conf.Envoy.MaximumResourcePathLengthInKB != -1 && (isResourcePathLimitExceeds(path, int(conf.Envoy.MaximumResourcePathLengthInKB))) {
if conf.Envoy.MaximumResourcePathLengthInKB != -1 &&
isResourcePathLimitExceeds(path, int(conf.Envoy.MaximumResourcePathLengthInKB)) {
return nil, errors.New("The path " + path + " exceeds maximum allowed length")
}
// Checks for resource level security. (security is disabled in resource level using x-wso2-disable-security extension)
Expand Down
7 changes: 3 additions & 4 deletions adapter/internal/oasparser/model/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/go-openapi/spec"
"github.com/google/uuid"

"github.com/wso2/product-microgateway/adapter/config"
logger "github.com/wso2/product-microgateway/adapter/internal/loggers"
)
Expand All @@ -46,11 +45,11 @@ func (swagger *MgwSwagger) SetInfoSwagger(swagger2 spec.Swagger) error {
swagger.vendorExtensions = swagger2.VendorExtensible.Extensions
swagger.securityScheme = setSecurityDefinitions(swagger2)
swagger.security = swagger2.Security
parsedEndpoints, epParsingError := setResourcesSwagger(swagger2)
if epParsingError != nil {
parsedResources, resourceParsingError := setResourcesSwagger(swagger2)
if resourceParsingError != nil {
return errors.New("one of the resource paths exceeds maximum allowed content length")
}
swagger.resources = parsedEndpoints
swagger.resources = parsedResources
swagger.apiType = HTTP
swagger.xWso2Basepath = swagger2.BasePath
// According to the definition, multiple schemes can be mentioned. Since the microgateway can assign only one scheme
Expand Down
2 changes: 2 additions & 0 deletions resources/conf/config.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ sandboxVhost = "sandbox.host"
systemHost = "localhost"
# Hostname for API Resources exposed within the cluster (eg: /.wellknown/jwks and /testkey)
internalServiceHost = "localhost"
# Allowed maximum resource path content size in KB
maximumResourcePathLengthInKB = -1

# Configurations of key store used in Choreo Connect Router
[router.keystore]
Expand Down

0 comments on commit e860b9e

Please sign in to comment.