I'm trying to simplify our existing guard and strategy since it seems there is a lot of bloat that is unnecessary. I'm having a bit of a hard time figuring out what parts are bloat and what parts are necessary though.
The validate method of our strategy looked something like this:
async validate(payload?: JwtPayload): Promise<JwtPayload> {
if (!payload) {
throw new UnauthorizedException();
}
if (payload.iss !== 'Issuer') {
throw new UnauthorizedException();
}
return payload;
}
I looked through the NestJS/Passport code and it looks like there is no instance where payload would be falsy. Aside from that, I am taking care of validating the issuer by specifying it in jsonWebTokenOptions.
So it seems like the new method should just be:
async validate(payload: JwtPayload): Promise<JwtPayload> {
return payload;
}
But something feels wrong with that considering validate was defined as an abstract method instead of having that be the default.
Is there anything wrong with doing that, or is that normal enough for a simple strategy?