
Explore how JWT authentication works behind the scenes, implement access and refresh tokens, and build a secure Node and Express API integrated with React for all experience levels.
Meet your instructor, Nikkatsu, a front-end developer with three years of experience, who invites questions in the course Q&A and aims to help you learn by teaching.
Explain how an api acts as a gateway between front-end apps and back-end infrastructure, defining endpoints and handling requests with common http methods and status codes.
Learn what jwt is and how it works by using access and refresh tokens, bearer authorization, and short-lived tokens to securely verify user identity in a stateless api.
Install mac prerequisites, including node 14 via node version manager (nvm), then install MongoDB community server and follow the MongoDB docs for your setup.
Install the Windows prerequisites: Node.js version 14, verify with node -v, install MongoDB community server with MongoDB Compass, then launch mongod and view databases.
Sign up for a free MongoDB Atlas cluster, set up a production database with a replica set, and configure admin access, IP whitelisting, and environment variables for API connections.
Follow a plan of action to set up mongodb, build an express API, test with postman, and implement middleware, environment variables, user models, and a rate limiter for jwt authentication.
Set up a MongoDB server, create a new API user, and initialize a course database with a users collection and a sample entry. Then verify data by querying the collection.
Set up a basic express api server by initializing the project, installing express, creating server code, defining a get endpoint, and testing with postman to return hello world on 3000.
Learn to use environment variables to configure an api for development and production, install and set up dotenv, create a .env file, and access values via process.env.
Explore the model-route-controller pattern for structuring Node APIs with Mongoose, defining schemas, routes, controllers, and middleware. Implement a rate limiter to protect the API and handle requests.
Implement a user model with mongoose, including email, password, email confirmed, tokens for refresh, and a password reset, then test by creating a user in dev and production databases.
Implement the user controller to handle business logic for creating a new user, export it, wire the user model, and test with Postman for upcoming routes.
Implement user routes by creating a routes directory, wiring an express router to the controller, and exposing a test route under the api path for server integration.
Implement an api rate limiter using the express rate limit package to throttle requests, prevent api spam, and protect the database with a configurable time window.
Test the api on development and production servers, reset the local users collection for a clean database, verify user creation with postman, and note the upcoming GWC authentication section.
Plan the implementation of JWT authentication with an access token verification middleware, refresh tokens, secure registration with input validation, email confirmation via Mail Trap and nodemailer, and testing.
Develop and test a jwt access token flow by signing a token with a payload and secret, then verify it via a middleware that checks the authorization header.
Implement user registration with input validation using Joy, hash passwords securely, enforce unique emails, save the user, and issue a short-lived JWT access token for authentication.
Implement refresh token functionality to issue new access tokens and revoke tokens by storing per-user refresh tokens, with separate secrets and expiry settings.
Explore mail trap, a fake smtp mail server that captures test emails for previewing delivery, and learn to set up the smtp workflow in a Node.js project.
Implement email confirmation with mail trap and node mailer, sending a verification token to user emails and enabling verification via a confirm token route.
Implement login functionality with login schema validation and email lookup. Verify passwords with decrypt/compare, generate access and refresh tokens, and enforce a 25-token refresh limit.
Implement password reset functionality by generating a reset token, hashing the provisional password, storing expiry, and sending a confirmation email via dedicated endpoints.
Run and test a complete jwt authentication api with node and mongo, using postman to register, confirm emails, and manage access tokens, refresh tokens, login, and password reset.
Learn key API and JWT concepts to get you up to speed with the benefits of setting up modern JSON Web Token authentication through a microservice. Covering:
What is API and how does it work?
What is JWT and how does it work?
Setting Up MongoDB Atlas & Community Server
Setting Up Express API Server
Model-Route-Controller Design Pattern Implementation
Access Token Verification Middleware
Refresh Token Functionality
Login & Registration Functionality
Email Confirmation & Password Reset Functionality
Email Change Functionality
Here is what you will get with this course:
1. Complete beginner to API & JWT concepts – You will learn what API and JWT is, how they work and how you can practically implement them into a fully functional microservice that can be integrated with any front-end and back-end.
2. Useful resources – You will get useful PDF resources and code templates as you move towards progressing through the lectures. The PDF files will be in form of quick explanation guides and the code templates will include the previous functional code and code snippets.
3. Real-world challenges – At the end of some section you will be given at least one mini challenge to extend the functionality of the API before moving onto the next section, just to push you a little further when it comes to self-teaching and learning new things.
4. Advanced concepts & security - You will build an API that is completely secure and takes into consideration security holes and insecure practices. This will help all beginners, intermediate and advanced programmers to build a secure back-end and front-end integration.
5. Ask me anything – I understand that you may have questions about any aspect of the course, therefore I am more than happy to answer any questions in Q&A section within a very timely manner!