Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarity on identitySource and authorization header in authorizers #1766

Open
jonlinkens opened this issue Feb 29, 2024 · 0 comments
Open

Clarity on identitySource and authorization header in authorizers #1766

jonlinkens opened this issue Feb 29, 2024 · 0 comments

Comments

@jonlinkens
Copy link

jonlinkens commented Feb 29, 2024

I'm upgrading from v8.4.0 to 13.3.3 and have started running into this error:

✖ Identity Source is null for header authorization (λ: authorizer)

my config looks something like this:

custom:
  authorizers:
    myAuthorizer:
      name: myAuthorizer
      type: 'request'
      resultTtlInSeconds: 600
      identitySource: method.request.header.access-key

Looking through the source code, this error originates from here:

let finalAuthorization
if (identitySourceType !== IDENTITY_SOURCE_TYPE_NONE) {
if (authorization === undefined) {
log.error(
`Identity Source is null for ${identitySourceType} ${identitySourceField} (λ: ${authFunName})`,
)

Looking further up in the file, it seems that the header name is enforced as authorization. I'm using a JWT header that is named something else and can't be easily changed, so this is problematic. What's the reasoning behind enforcing this? If it's to comply with standards it might be nice to allow people to bail out for the sake of backwards compatibility.

It also seems like the identitySource config is ignored here - am I misunderstanding its usage?

As a workaround, if I set an authorization header with any string value, everything works fine - but I would prefer to avoid this.

Previously in v8.4.0 this wasn't a problem, because this header check would only happen if the type wasn't request:

} else {
const authorization = req.headers[identityHeader]

Appreciate any help here, thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant