diff --git a/runtime/config-deployer-service/ballerina/APIClient.bal b/runtime/config-deployer-service/ballerina/APIClient.bal index 5fcdd78ee..1975b4e11 100644 --- a/runtime/config-deployer-service/ballerina/APIClient.bal +++ b/runtime/config-deployer-service/ballerina/APIClient.bal @@ -363,9 +363,15 @@ public class APIClient { authTypes.jwt = {header: jwtAuthentication.headerName, sendTokenToUpstream: jwtAuthentication.sendTokenToUpstream, disabled: !jwtAuthentication.enabled, audience: jwtAuthentication.audience}; } else if authentication.authType == "APIKey" && authentication is APIKeyAuthentication { APIKeyAuthentication apiKeyAuthentication = check authentication.cloneWithType(APIKeyAuthentication); - authTypes.apiKey = []; - authTypes.apiKey.push({'in: "Header", name: apiKeyAuthentication.headerName, sendTokenToUpstream: apiKeyAuthentication.sendTokenToUpstream}); - authTypes.apiKey.push({'in: "Query", name: apiKeyAuthentication.queryParamName, sendTokenToUpstream: apiKeyAuthentication.sendTokenToUpstream}); + model:APIKey[] apiKeys = []; + + if apiKeyAuthentication.headerEnable { + apiKeys.push({'in: "Header", name: apiKeyAuthentication.headerName, sendTokenToUpstream: apiKeyAuthentication.sendTokenToUpstream}); + } + if apiKeyAuthentication.queryParamEnable { + apiKeys.push({'in: "Query", name: apiKeyAuthentication.queryParamName, sendTokenToUpstream: apiKeyAuthentication.sendTokenToUpstream}); + } + authTypes.apiKey = apiKeys; } else if authentication.authType == "mTLS" { MTLSAuthentication mtlsAuthentication = check authentication.cloneWithType(MTLSAuthentication); isMTLSMandatory = mtlsAuthentication.required == "mandatory"; diff --git a/runtime/config-deployer-service/ballerina/resources/apk-conf-schema.yaml b/runtime/config-deployer-service/ballerina/resources/apk-conf-schema.yaml index baf1c0ac8..9c9847c50 100644 --- a/runtime/config-deployer-service/ballerina/resources/apk-conf-schema.yaml +++ b/runtime/config-deployer-service/ballerina/resources/apk-conf-schema.yaml @@ -150,7 +150,7 @@ components: headerEnable: type: boolean default: true - audience: + audience: type: array default: [] items: @@ -173,7 +173,7 @@ components: default: false headerName: type: string - example: Authorization + example: apikey default: apikey queryParamName: type: string diff --git a/runtime/config-deployer-service/ballerina/tests/resources/apk-schema.json b/runtime/config-deployer-service/ballerina/tests/resources/apk-schema.json index ee39eacd3..9eb12e129 100644 --- a/runtime/config-deployer-service/ballerina/tests/resources/apk-schema.json +++ b/runtime/config-deployer-service/ballerina/tests/resources/apk-schema.json @@ -213,7 +213,7 @@ }, "headerName": { "type": "string", - "example": "Authorization", + "example": "apikey", "default": "apikey" }, "queryParamName": { diff --git a/runtime/config-deployer-service/ballerina/types.bal b/runtime/config-deployer-service/ballerina/types.bal index b68f2f2ee..41fa29730 100644 --- a/runtime/config-deployer-service/ballerina/types.bal +++ b/runtime/config-deployer-service/ballerina/types.bal @@ -278,7 +278,7 @@ public type APIKeyAuthentication record {| string headerName = "apiKey"; string queryParamName = "apiKey"; boolean headerEnable = true; - boolean queryParamEnable = true; + boolean queryParamEnable = false; |}; # Mutual SSL configuration of this API diff --git a/runtime/config-deployer-service/docker/config-deployer/conf/apk-schema.json b/runtime/config-deployer-service/docker/config-deployer/conf/apk-schema.json index c1f5c3402..870b4a389 100644 --- a/runtime/config-deployer-service/docker/config-deployer/conf/apk-schema.json +++ b/runtime/config-deployer-service/docker/config-deployer/conf/apk-schema.json @@ -156,11 +156,16 @@ "required": { "type": "string", "default": "mandatory", - "enum": ["mandatory", "optional"] + "enum": [ + "mandatory", + "optional" + ] }, "authType": { "type": "string", - "enum": ["JWT"] + "enum": [ + "JWT" + ] }, "sendTokenToUpstream": { "type": "boolean", @@ -253,7 +258,7 @@ }, "headerName": { "type": "string", - "example": "Authorization", + "example": "apikey", "default": "apikey" }, "queryParamName": { @@ -608,7 +613,7 @@ } } }, - "required":[ + "required": [ "target", "verb" ],