Skip to content

Commit

Permalink
Trim API key before use
Browse files Browse the repository at this point in the history
  • Loading branch information
damontecres committed Nov 12, 2024
1 parent d9072a7 commit c515ad6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@ class StashClient private constructor() {
}
}
if (useApiKey && server.apiKey.isNotNullOrBlank()) {
val cleanedApiKey = server.apiKey.trim()
builder =
builder.addInterceptor {
val request =
if (it.request().url.toString().startsWith(serverUrlRoot)) {
// Only set the API Key if the target URL is the stash server
it.request().newBuilder()
.addHeader(Constants.STASH_API_HEADER, server.apiKey)
.addHeader(Constants.STASH_API_HEADER, cleanedApiKey)
.build()
} else {
it.request()
Expand Down Expand Up @@ -331,11 +332,12 @@ class StashClient private constructor() {
}
}
if (server.apiKey.isNotNullOrBlank()) {
val cleanedApiKey = server.apiKey.trim()
builder =
builder.addInterceptor {
val request =
it.request().newBuilder()
.addHeader(Constants.STASH_API_HEADER, server.apiKey.trim())
.addHeader(Constants.STASH_API_HEADER, cleanedApiKey)
.build()
it.proceed(request)
}
Expand Down

0 comments on commit c515ad6

Please sign in to comment.