hydra-newmedia / passport-headerapikey

Api key authentication strategy for Passport, which only handles headers (not body fields).
28 stars 6 forks source link

verified callback expected to be the last argument #6

Closed KinIcy closed 4 years ago

KinIcy commented 4 years ago

I'm using nestjs passport, currently, I have a problem while implementing this strategy. Nestjs passport expects the verified callback to be the last argument, but for this strategy, it isn't the last one, even if I set passReqToCallback = false it set an undefined in the last parameter.

I'm pretty new to passport, so I don't know if the verified callback in the last spot is something standard, but from my point of view, it seems easier to solve this issue from the strategy itself with something like this:

const verifyParams = [apiKey, verified];
if (this.passReqToCallback) verifyParams.push(req);
this.verify(...verifyParams);

Replaces: https://github.com/hydra-newmedia/passport-headerapikey/blob/11fbb479e01eacbd9248167d92878ced4949b4ec/src/Strategy.ts#L62

guischdi commented 4 years ago

fixed this in https://github.com/hydra-newmedia/passport-headerapikey/commit/70308832558ab22ec7c79fe5dfa9b5be59c2874b and released it as v1.2.1