node-oauth2-jwt-bearer
node-oauth2-jwt-bearer copied to clipboard
Support: Implementation with NEstJS functional?
Description
Hi there, just a support question:
I've been trying to implement auth0 to use for our NestJs app.
I followed your tutorial on youtube: https://www.youtube.com/watch?v=JzndSOAb6SQ But this video uses not this actual package, but the other ones that were previously in place (express-jwt, express-jwt-authz, and jwks-rsa)
I'm just curious to know if this new one is easily implementable for a NestJs app as well? and How different should it be done?
Hi @m3c-ode - thanks for raising this
Currently we only publish express-oauth2-jwt-bearer
for Express.js apps - but if you can get Nest.js working with express-jwt
there's no reason why you couldn't get express-oauth2-jwt-bearer
working with Nest.js - I don't have an example for you though.
We'd like to natively support other frameworks in the future, but currently that's just limited to Express.js
Ok I'm asking because I've tried implementing it but was unsuccessful doing so so far. So I just used the "previous versions" of the packages. So the one that are used in your NestJS YouTube video and articles.
On Wed., Jun. 22, 2022, 8:32 a.m. Adam Mcgrath, @.***> wrote:
Hi @m3c-ode https://github.com/m3c-ode - thanks for raising this
Currently we only publish express-oauth2-jwt-bearer for Express.js apps - but if you can get Nest.js working with express-jwt there's no reason why you couldn't get express-oauth2-jwt-bearer working with Nest.js - I don't have an example for you though.
We'd like to natively support other frameworks in the future, but currently that's just limited to Express.js
— Reply to this email directly, view it on GitHub https://github.com/auth0/node-oauth2-jwt-bearer/issues/63#issuecomment-1163267226, or unsubscribe https://github.com/notifications/unsubscribe-auth/AX2GJOONZBDPQYWZC6HSS3LVQMWYDANCNFSM5ZJ6GIZA . You are receiving this because you were mentioned.Message ID: @.***>
@adamjmcgrath Please consider publishing access-token-jwt and oauth2-bearer so the community can build custom solutions. 😄
It's not the NestJS way to utilize middleware to perform auth and authz.
For anyone else looking to use this middleware with Nest, you can try something like this in your app.module.ts:
import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common';
import { auth } from 'express-oauth2-jwt-bearer';
@Module({
imports: [],
controllers: [],
providers: []
})
export class AppModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(
auth({
issuerBaseURL: process.env.AUTH0_ISSUER,
audience: process.env.AUTH0_AUDIENCE
}),
// ... any other middleware
)
.forRoutes({
path: '*',
method: RequestMethod.ALL
});
}
}
auth0-access-token-jwt Is it really the only way to use Auth0 with Node.js (no express) to verify access tokens? I just have accessToken string and want to verify it, why is it so complicated?
I have an electron desktop app that communicates with my Node.js API. The electron app sends access token in a Authorization
header, like this: Authorization: Bearer <access_token>
. I set it manually for each http request, not a big deal. The access token comes from Auth0. How can I verify this token in my Node.js server? @adamjmcgrath
@adamjmcgrath Please consider publishing access-token-jwt and oauth2-bearer so the community can build custom solutions. 😄
It's not the NestJS way to utilize middleware to perform auth and authz.
This would be great to have!