Skip to content

Commit

Permalink
Safer X-API-Key redaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Remco van 't Veer committed Feb 11, 2025
1 parent ca69a41 commit 5fb1a8b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/dil_demo/portbase.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
[dil-demo.i18n :refer [t]]
[dil-demo.web-utils :as w]))

(def x-api-key-header "X-API-Key")

(defn- api-request
[{:keys [api-base-url api-key]}
{:keys [method path body]}]
(cond-> {:method method
:uri (str api-base-url path)
:headers (cond-> {"X-API-Key" api-key
"Accept" "application/json"}
:headers (cond-> {x-api-key-header api-key
"Accept" "application/json"}
body (assoc :content-type "application/json"))}
body (assoc :body (json/write-str body))))

Expand Down Expand Up @@ -72,7 +74,7 @@
[(t "explanation/request-portbase-event")
{:http-request (-> r
:request
(update :headers assoc "X-API-Key" "[REDACTED]"))
(update :headers assoc x-api-key-header "[REDACTED]"))
:http-response (-> r
(dissoc :request))}])))
res
Expand Down

0 comments on commit 5fb1a8b

Please sign in to comment.