Skip to content

Commit b0bf397

Browse files
committed
add default masks
1 parent 4ec4c6c commit b0bf397

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Sources/SwiftAPIClient/Modifiers/LoggingModifier.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public extension APIClient.Configs {
8686
/// The headers that should be masked in logs.
8787
/// - Returns: A `Set<HTTPField.Name>` containing the names of headers to be masked.
8888
var logMaskedHeaders: Set<HTTPField.Name> {
89-
get { self[\.logMaskedHeaders] ?? [.authorization] }
89+
get { self[\.logMaskedHeaders] ?? .defaultMaskedHeaders }
9090
set { self[\.logMaskedHeaders] = newValue }
9191
}
9292
}
@@ -114,4 +114,22 @@ extension APIClient.Configs {
114114
}
115115
}
116116

117+
extension Set<HTTPField.Name> {
118+
119+
public static var defaultMaskedHeaders: Set<HTTPField.Name> = [
120+
.authorization,
121+
.authenticationInfo,
122+
.proxyAuthorization,
123+
.proxyAuthenticationInfo,
124+
HTTPField.Name("Authentication")!,
125+
HTTPField.Name("Proxy-Authentication")!,
126+
HTTPField.Name("X-API-Key")!,
127+
HTTPField.Name("Api-Key")!,
128+
HTTPField.Name("X-Auth-Token")!,
129+
.cookie,
130+
.setCookie,
131+
HTTPField.Name("Client-Secret")!,
132+
]
133+
}
134+
117135
private let defaultLogger = Logger(label: "swift-api-client")

0 commit comments

Comments
 (0)