I use nestjs, and use node-oidc-provider package to make and identity provider, but currently stack to validate the jwt in my strategy middleware, which i follow from this tutorial
https://auth0.com/blog/developing-a-secure-api-with-nestjs-adding-authorization/
in my oidc config i have set jwk keys, set resource indicators feature to format my access token in jwt format, so thats why i follow that tutorial, i think i have implemented correctly but i still get 401 unathorized
resourceIndicators: {
defaultResource(ctx) {
return ctx.origin;
},
getResourceServerInfo(ctx, resourceIndicator, client) {
return {
scope: client.scope as string,
audience: 'account',
accessTokenFormat: 'jwt',
};
},
useGrantedResource(ctx, model) {
return true;
},
},
and here my strategy:
import { Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { passportJwtSecret } from 'jwks-rsa';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
constructor(config: ConfigService) {
super({
secretOrKeyProvider: passportJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: 'http://localhost:3000/oidc/jwks',
timeout: 300,
}),
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
audience: 'account',
issuer: 'http://localhost:3000',
algorithms: ['RS256'],
});
}
validate(payload: unknown): unknown {
return payload;
}
}
and this is the result of my decoded access token enter image description here
is there something i missing?