Skip to content

Commit

Permalink
fix(auth): match auth-provider header generically (#8474)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Walker-GM committed Jun 1, 2023
1 parent ac99ecc commit a208439
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/api/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import type { Decoded } from './parseJWT'
export type { Decoded }

// This is shared by `@redwoodjs/web`
const AUTH_PROVIDER_HEADER = 'Auth-Provider'
const AUTH_PROVIDER_HEADER = 'auth-provider'

export const getAuthProviderHeader = (event: APIGatewayProxyEvent) => {
return (
event?.headers[AUTH_PROVIDER_HEADER] ??
event?.headers[AUTH_PROVIDER_HEADER.toLowerCase()]
const authProviderKey = Object.keys(event?.headers ?? {}).find(
(key) => key.toLowerCase() === AUTH_PROVIDER_HEADER
)
if (authProviderKey) {
return event?.headers[authProviderKey]
}
return undefined
}

export interface AuthorizationHeader {
Expand Down

0 comments on commit a208439

Please sign in to comment.