Skip to content

Commit 1064c76

Browse files
chore: redact api-key headers in debug logs
1 parent 1ca2d2f commit 1064c76

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

orb-java-core/src/main/kotlin/com/withorb/api/core/http/LoggingHttpClient.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private constructor(
3131
/**
3232
* Sensitive headers to redact from logs.
3333
*
34-
* Defaults to `Set.of("Authorization")`.
34+
* Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`.
3535
*/
3636
@get:JvmName("redactedHeaders") val redactedHeaders: SortedSet<String>,
3737
/**
@@ -192,7 +192,8 @@ private constructor(
192192
class Builder internal constructor() {
193193

194194
private var httpClient: HttpClient? = null
195-
private var redactedHeaders: Set<String> = setOf("Authorization")
195+
private var redactedHeaders: Set<String> =
196+
setOf("authorization", "api-key", "x-api-key", "cookie", "set-cookie")
196197
private var clock: Clock = Clock.systemUTC()
197198
private var level: LogLevel? = null
198199

@@ -210,7 +211,7 @@ private constructor(
210211
/**
211212
* Sensitive headers to redact from logs.
212213
*
213-
* Defaults to `Set.of("Authorization")`.
214+
* Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`.
214215
*/
215216
fun redactedHeaders(redactedHeaders: Set<String>) = apply {
216217
this.redactedHeaders = redactedHeaders

orb-java-core/src/test/kotlin/com/withorb/api/core/http/LoggingHttpClientTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ internal class LoggingHttpClientTest {
870870
httpClient: HttpClient,
871871
level: LogLevel,
872872
clock: Clock = clockFrom(Instant.parse("1998-04-21T00:00:00Z")),
873-
redactedHeaders: Set<String> = setOf("Authorization"),
873+
redactedHeaders: Set<String> =
874+
setOf("authorization", "api-key", "x-api-key", "cookie", "set-cookie"),
874875
): LoggingHttpClient =
875876
LoggingHttpClient.builder()
876877
.httpClient(httpClient)

0 commit comments

Comments
 (0)