Skip to content

Commit

Permalink
adding endpoint security in dp to cp flow
Browse files Browse the repository at this point in the history
  • Loading branch information
CrowleyRajapakse committed Oct 23, 2024
1 parent f538a95 commit 97263ae
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 26 deletions.
30 changes: 30 additions & 0 deletions apim-apk-agent/pkg/managementserver/rest_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,36 @@ func createAPIYaml(apiCPEvent *APICPEvent) (string, string) {
"production_endpoints": map[string]interface{}{
"url": prodEndpoint,
},
"endpoint_security": map[string]interface{}{
"sandbox": map[string]interface{}{
"apiKeyValue": apiCPEvent.API.SandEndpointSecurity.APIKeyValue,
"apiKeyIdentifier": apiCPEvent.API.SandEndpointSecurity.APIKeyName,
"apiKeyIdentifierType": "HEADER",
"type": apiCPEvent.API.SandEndpointSecurity.SecurityType,
"username": apiCPEvent.API.SandEndpointSecurity.BasicUsername,
"password": apiCPEvent.API.SandEndpointSecurity.BasicPassword,
"enabled": apiCPEvent.API.SandEndpointSecurity.Enabled,
"additionalProperties": map[string]interface{}{},
"customParameters": map[string]interface{}{},
"connectionTimeoutDuration": -1.0,
"socketTimeoutDuration": -1.0,
"connectionRequestTimeoutDuration": -1.0,
},
"production": map[string]interface{}{
"apiKeyValue": apiCPEvent.API.ProdEndpointSecurity.APIKeyValue,
"apiKeyIdentifier": apiCPEvent.API.ProdEndpointSecurity.APIKeyName,
"apiKeyIdentifierType": "HEADER",
"type": apiCPEvent.API.ProdEndpointSecurity.SecurityType,
"username": apiCPEvent.API.ProdEndpointSecurity.BasicUsername,
"password": apiCPEvent.API.ProdEndpointSecurity.BasicPassword,
"enabled": apiCPEvent.API.ProdEndpointSecurity.Enabled,
"additionalProperties": map[string]interface{}{},
"customParameters": map[string]interface{}{},
"connectionTimeoutDuration": -1.0,
"socketTimeoutDuration": -1.0,
"connectionRequestTimeoutDuration": -1.0,
},
},
},
"policies": []string{"Unlimited"},
"gatewayType": "wso2/apk",
Expand Down
65 changes: 39 additions & 26 deletions apim-apk-agent/pkg/managementserver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,32 +124,34 @@ const (

// API holds the api data from adapter api event
type API struct {
APIUUID string `json:"apiUUID"`
APIName string `json:"apiName"`
APIVersion string `json:"apiVersion"`
IsDefaultVersion bool `json:"isDefaultVersion"`
Definition string `json:"definition"`
APIType string `json:"apiType"`
APISubType string `json:"apiSubType"`
BasePath string `json:"basePath"`
Organization string `json:"organization"`
SystemAPI bool `json:"systemAPI"`
APIProperties map[string]string `json:"apiProperties,omitempty"`
Environment string `json:"environment,omitempty"`
RevisionID string `json:"revisionID"`
SandEndpoint string `json:"sandEndpoint"`
ProdEndpoint string `json:"prodEndpoint"`
EndpointProtocol string `json:"endpointProtocol"`
CORSPolicy *CORSPolicy `json:"cORSPolicy"`
Vhost string `json:"vhost"`
SandVhost string `json:"sandVhost"`
SecurityScheme []string `json:"securityScheme"`
AuthHeader string `json:"authHeader"`
APIKeyHeader string `json:"apiKeyHeader"`
Operations []OperationFromDP `json:"operations"`
SandAIRL *AIRL `json:"sandAIRL"`
ProdAIRL *AIRL `json:"prodAIRL"`
AIConfiguration AIConfiguration `json:"aiConfiguration"`
APIUUID string `json:"apiUUID"`
APIName string `json:"apiName"`
APIVersion string `json:"apiVersion"`
IsDefaultVersion bool `json:"isDefaultVersion"`
Definition string `json:"definition"`
APIType string `json:"apiType"`
APISubType string `json:"apiSubType"`
BasePath string `json:"basePath"`
Organization string `json:"organization"`
SystemAPI bool `json:"systemAPI"`
APIProperties map[string]string `json:"apiProperties,omitempty"`
Environment string `json:"environment,omitempty"`
RevisionID string `json:"revisionID"`
SandEndpoint string `json:"sandEndpoint"`
SandEndpointSecurity EndpointSecurity `json:"sandEndpointSecurity"`
ProdEndpoint string `json:"prodEndpoint"`
ProdEndpointSecurity EndpointSecurity `json:"prodEndpointSecurity"`
EndpointProtocol string `json:"endpointProtocol"`
CORSPolicy *CORSPolicy `json:"cORSPolicy"`
Vhost string `json:"vhost"`
SandVhost string `json:"sandVhost"`
SecurityScheme []string `json:"securityScheme"`
AuthHeader string `json:"authHeader"`
APIKeyHeader string `json:"apiKeyHeader"`
Operations []OperationFromDP `json:"operations"`
SandAIRL *AIRL `json:"sandAIRL"`
ProdAIRL *AIRL `json:"prodAIRL"`
AIConfiguration AIConfiguration `json:"aiConfiguration"`
}

// AIRL holds AI ratelimit related data
Expand All @@ -161,6 +163,17 @@ type AIRL struct {
RequestCount *uint32 `json:"requestCount"`
}

// EndpointSecurity holds the endpoint security information
type EndpointSecurity struct {
Enabled bool `json:"enabled"`
SecurityType string `json:"securityType"`
APIKeyName string `json:"apiKeyName"`
APIKeyValue string `json:"apiKeyValue"`
APIKeyIn string `json:"apiKeyIn"`
BasicUsername string `json:"basicUsername"`
BasicPassword string `json:"basicPassword"`
}

// AIConfiguration holds the AI configuration
type AIConfiguration struct {
LLMProviderID string `json:"llmProviderID"`
Expand Down

0 comments on commit 97263ae

Please sign in to comment.