Skip to content

Commit

Permalink
ensure key for header security is lower case (#4456)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Feb 15, 2025
1 parent c827931 commit 3e7ce97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-dingos-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

ensure key for header security is lower case
5 changes: 3 additions & 2 deletions packages/platform/src/HttpApiBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,9 @@ export const securityDecode = <Security extends HttpApiSecurity.HttpApiSecurity>
)
}
case "ApiKey": {
const key = self.in === "header" ? self.key.toLowerCase() : self.key
const schema = Schema.Struct({
[self.key]: Schema.String
[key]: Schema.String
})
const decode = unify(
self.in === "query"
Expand All @@ -983,7 +984,7 @@ export const securityDecode = <Security extends HttpApiSecurity.HttpApiSecurity>
)
return Effect.match(decode, {
onFailure: () => Redacted.make("") as any,
onSuccess: (match) => Redacted.make(match[self.key])
onSuccess: (match) => Redacted.make(match[key])
})
}
case "Basic": {
Expand Down

0 comments on commit 3e7ce97

Please sign in to comment.