Create a NodeJS + MongoDB Rest API [Part: 5]

preview_player
Показать описание
In this part we add JWT authentication with passport-jwt and we also make use of the toJSON methods of mongoose.

Рекомендации по теме
Комментарии
Автор

Your english is fine. Great video as always, i didn't know about toJSON in mongoose, now i do. Thanks!

theRealBraZee
Автор

Migrating passport-jwt from 2.x.x to 3.x.x

Version 3.0.0 removes the ExtractJwt.fromAuthHeader() extractor function that would extract JWT's from Authorization headers with the auth scheme 'jwt'. The default authorization scheme of 'jwt' as the was not RFC 6750 compliant. The extractor was replaced with The removal of ExtractJwt.fromAuthHeader() was done to clearly change the API so any code relying on the old API would clearly break, hopefully saving people some debugging time.

If you want to maintain the behavior of ExtractJwt.fromAuthHeader() when switching to v3.3.0, simply replace it with in your implementation.

jeffersontarira
Автор

I'm learning a lot, however I have one comment. It would be great if you'd stick to an "app" like the meetup app and work from the different angles like API, client etc rather than building separate types of apps. I find it too often with tutorials they tend to only cover the really basics and after that you're on your own but kinda lost. Keep up the good work Emmanuel

lassestube
Автор

Thank you very much for this great tutorial.
at the minute: 8:53 i see this error on my console:
throw new TypeError('JwtStrategy requires a secret or key');
^
TypeError: JwtStrategy requires a secret or key

maybe missing another options for passport-jw ?
thank you!

marcoamodio
Автор

Hi, can anyone explains me step-by-step this line in the auth.services.js ?

import { Strategy as JWTStrategy, ExtractJwt } from 'passport-jwt';

Thank you.

themobilife
join shbcf.ru