Skip to content

Commit a9bb6a1

Browse files
committed
Stop sending API key as query parameter
Send only as an HTTP header, which is supported by ZAP since 2.6.0. Signed-off-by: thc202 <[email protected]>
1 parent 584ae5f commit a9bb6a1

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Changed
9+
- Stop sending the API key as query parameter, not needed since ZAP 2.6.0.
10+
811
### Deprecated
912
- The following APIs were deprecated:
1013
- `Exportreport`

subprojects/zap-clientapi/src/main/java/org/zaproxy/clientapi/core/ClientApi.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public class ClientApi {
9292
private static final int DEFAULT_CONNECTION_POOLING_IN_MS = 1000;
9393

9494
private static final String ZAP_API_KEY_HEADER = "X-ZAP-API-Key";
95-
private static final String ZAP_API_KEY_PARAM = "apikey";
9695

9796
private Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8090));
9897
private boolean debug = false;
@@ -486,10 +485,6 @@ private HttpRequest buildZapRequest(
486485
sb.append(method);
487486
sb.append('/');
488487
if (params != null) {
489-
if (apiKey != null && !apiKey.isEmpty()) {
490-
params.put(ZAP_API_KEY_PARAM, apiKey);
491-
}
492-
493488
sb.append('?');
494489
for (Map.Entry<String, String> p : params.entrySet()) {
495490
sb.append(encodeQueryParam(p.getKey()));
@@ -499,13 +494,6 @@ private HttpRequest buildZapRequest(
499494
}
500495
sb.append('&');
501496
}
502-
} else if (apiKey != null && !apiKey.isEmpty()) {
503-
// Send the API key even if there are no parameters,
504-
// older ZAP versions might need it as (query) parameter.
505-
sb.append('?');
506-
sb.append(encodeQueryParam(ZAP_API_KEY_PARAM));
507-
sb.append('=');
508-
sb.append(encodeQueryParam(apiKey));
509497
}
510498

511499
HttpRequest request = new HttpRequest(createUrl(sb.toString()));

0 commit comments

Comments
 (0)