0 to Auth in an Hour Using NodeJS SDK

Rate this content
Bookmark

Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.


We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:

- User authentication - Managing user interactions, returning session / refresh JWTs

- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions


At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.


Table of contents

- A quick intro to core authentication concepts

- Coding

- Why passwordless matters


Prerequisites

- IDE for your choice

- Node 18 or higher

FAQ

Dscope is an authentication platform designed to assist developers in implementing secure authentication methods seamlessly into their applications.

The workshop led by Asaf will focus on adding passwordless authentication to a standard Node application. It includes an overview of basic authentication concepts, the integration of an authentication layer into an existing application, and practical coding sessions.

Participants are expected to have a basic understanding of Node and the Express framework, a GitHub account, an IDE of choice, and Node version 18 or higher.

Passwordless authentication is a security approach that does not require users to enter a password. Instead, it uses alternative methods such as biometrics, magic links, or one-time passwords to verify user identity.

Session management can be handled through server-side sessions where the server stores session data and provides a session ID to the client, or through client-side tokens such as JSON Web Tokens (JWTs), which contain user credentials and are validated by the server with each request.

Asaf discusses three primary types of authentication factors: something you know (like a password), something you have (such as a mobile device), and something you are (like a fingerprint or facial recognition).

JWT, or JSON Web Token, is a compact, URL-safe means of representing claims to be transferred between two parties. In authentication, JWTs are used to securely transmit information about an authenticated party and are signed for integrity verification.

Refresh tokens are used to maintain a user's authentication status without requiring them to log in multiple times. When an access token expires, a refresh token can be used to obtain a new access token, ensuring continuous authentication.

Participants will gain a better understanding of authentication workflows, learn to add authentication layers to Node applications, and handle both passwordless and traditional authentication methods.

Asaf Shen
Asaf Shen
63 min
10 Apr, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Workshop focuses on adding passwordless authentication to a node application, covering basic authentication concepts and the importance of authentication for application security. It explores session management using server-side sessions and client-side tokens like JWTs. The Workshop demonstrates the implementation of various authentication methods, including one-time password and OAuth. It also discusses the validation and refreshing of session tokens, as well as the customization of authentication methods and the storage of public keys for multiple instances.

1. Introduction to Authentication Workshop

Short description:

In this workshop, we will be adding passwordless authentication to a standard node application. We will cover basic authentication concepts, the importance of authentication for application security, and how to incorporate authentication into a node application. By the end of the workshop, you will have a better understanding of the authentication workflow and be able to add authentication to your own applications.

Let me start with introducing myself. My name is Asaf. I'm a software engineer at Dscope. Dscope is an authentication platform that helps all developers facilitate authentication in a secure manner.

In the next workshop, we are going to add a passwordless authentication to a standard node application. We are going to start by overviewing some basic authentication concepts and basically to go over the flaws that we are going to add. This is like a background and knowledge that needs to that we need to acquire in order to incorporate the authentication properly. And this will probably take about 15 minutes and in the rest of the time, we are going to take an existing application and it's the authentication layer for it.

If you ask what's in it for me in this workshop. So I believe that by the end of the workshop, you will be you have a better understanding of the authentication workflow. This is something that may seem a bit intimidating at start, but I think it's quite simple if you go over it well. And maybe more importantly, I think you will be able to take a standard of application and add authentication on top of it. If you have any node application, you can take it and add authentication in a few steps.

Like I said before, we start with the core concept and afterwards we are going to do the coding and I'll give more information about that later. Hello to the person who wrote the chat. I'm very excited as well. I'm going to assume that you have a basic understanding on Node and the Express framework. The application is written in TypeScript. So, probably if you also know JavaScript, I think it's enough. We don't heavily use TypeScript, but the Node application will be written in TypeScript. Also, just to prepare for the coding session, if you want to do it on your own, you should have a GitHub account, any ID that you choose to code on, and Node version 18 or higher. So, this is up to you, but of course, I'm going to do it here, so this is optional, of course.

Let's start with covering the very basic concept. So, what is authentication? What authentication is? The way I see it, authentication process is basically verifying someone's identity. The internet is a very distributed place, so if someone on another machine says that there are some someone, whether it's a user or a system or a device, they basically have to prove it before they want to access the application, the application, specific resource on the application or the system. This is a very, very essential aspect of the application security. And this is a, we use the authentication layer basically to protect our system for unauthorized access. And this is something that is super important in the digital age. There are so many data breaches, identity thefts in the world. Doing proper authentication is crucial for your application security.

2. Authentication Importance and Factors

Short description:

We will discuss the importance of investing in secure applications and the different authentication factors, such as something you know, something you have, and something you are. Additionally, we will explore new factors like geographic and behavioral factors. After verifying the proof and identity, the application grants the user access through a session or token.

And we hear more and more about incidents of unauthorized access. And if we want to write a secure application, we should invest in it. Just as a side note, we have a really good learning center with a lot of graphical assets there. I sometimes go back there and refresh my memory. And there is a link in the presentation which is also going to be shown.

So what are we going to build? And this is more related to the flows that we want to add. If we break down the parts of the steps of authentication, we can basically break it down into two major steps. The first step is when the user wants to access the resource or the application in the first time, they should authenticate. So usually it starts by a user wants to access the resource. He submits some kind of request to access. The user usually provides its identity. This can be more basically an email, a username. Mobile number, social security ID or what? This is very application specific. And a proof is usually something that basically as you prove who you are.

There are a few authentication proof factors that usually they call factors. An authentication factor is basically based on something you know, for example, a password or maybe a security question. By the way, a quick tip in security question, usually if you care about security, don't answer the real information because usually this is something that is very simple to get this information, like your pet name, etc. Another authentication factor is something you have, a very common example for this is a mobile device. So if I send you an SMS with a code, and then you give back the code to me, I can say, this is basically proof that you have a mobile device. And also something you, basically something you are or something you inherit. This is a relatively new factor of biometric information, either with a fingerprint or face recognition. I also heard about solutions that scan iRetina and stuff like this. Did someone have an idea or heard about more authentication factor other than the three that we mentioned? Something you know, something you have, something you are?

So just like, and just to share from our experience, there are somewhat new factors of a geographic factor. So basically, if you log in from a certain geographic location, this is something that usually makes you either suspicious or not suspicious. If you heard about an impossible traveler scenario when a same user accesses the same application from both locations, that basically a person cannot change the location in that amount of time. And another one is behavioral factor. Basically, if you behave in a way that is not suits you, like you access results that you are not used to access or the rate, this is another factor. So basically, after the application gets the proof and the identity, it's verified, basically check that they match. And then the application grants the user access. This access usually grants in a way of a session or a token.

QnA

Watch more workshops on topic

Using CodeMirror to Build a JavaScript Editor with Linting and AutoComplete
React Day Berlin 2022React Day Berlin 2022
86 min
Using CodeMirror to Build a JavaScript Editor with Linting and AutoComplete
Top Content
WorkshopFree
Hussien Khayoon
Kahvi Patel
2 authors
Using a library might seem easy at first glance, but how do you choose the right library? How do you upgrade an existing one? And how do you wade through the documentation to find what you want?
In this workshop, we’ll discuss all these finer points while going through a general example of building a code editor using CodeMirror in React. All while sharing some of the nuances our team learned about using this library and some problems we encountered.
Node.js Masterclass
Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Top Content
Workshop
Matteo Collina
Matteo Collina
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
Testing Web Applications Using Cypress
TestJS Summit - January, 2021TestJS Summit - January, 2021
173 min
Testing Web Applications Using Cypress
WorkshopFree
Gleb Bahmutov
Gleb Bahmutov
This workshop will teach you the basics of writing useful end-to-end tests using Cypress Test Runner.
We will cover writing tests, covering every application feature, structuring tests, intercepting network requests, and setting up the backend data.
Anyone who knows JavaScript programming language and has NPM installed would be able to follow along.
Build a powerful DataGrid in few hours with Ag Grid
React Summit US 2023React Summit US 2023
96 min
Build a powerful DataGrid in few hours with Ag Grid
WorkshopFree
Mike Ryan
Mike Ryan
Does your React app need to efficiently display lots (and lots) of data in a grid? Do your users want to be able to search, sort, filter, and edit data? AG Grid is the best JavaScript grid in the world and is packed with features, highly performant, and extensible. In this workshop, you’ll learn how to get started with AG Grid, how we can enable sorting and filtering of data in the grid, cell rendering, and more. You will walk away from this free 3-hour workshop equipped with the knowledge for implementing AG Grid into your React application.
We all know that rolling our own grid solution is not easy, and let's be honest, is not something that we should be working on. We are focused on building a product and driving forward innovation. In this workshop, you'll see just how easy it is to get started with AG Grid.
Prerequisites: Basic React and JavaScript
Workshop level: Beginner
0 to Auth in an hour with ReactJS
React Summit 2023React Summit 2023
56 min
0 to Auth in an hour with ReactJS
WorkshopFree
Kevin Gao
Kevin Gao
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool. There are multiple alternatives that are much better than passwords to identify and authenticate your users - including SSO, SAML, OAuth, Magic Links, One-Time Passwords, and Authenticator Apps.
While addressing security aspects and avoiding common pitfalls, we will enhance a full-stack JS application (Node.js backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session securely for subsequent client requests, validating / refreshing sessions- Basic Authorization - extracting and validating claims from the session token JWT and handling authorization in backend flows
At the end of the workshop, we will also touch other approaches of authentication implementation with Descope - using frontend or backend SDKs.
Build and Deploy a Backend With Fastify & Platformatic
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Matteo Collina
Matteo Collina
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
Do you have a large product built by many teams? Are you struggling to release often? Did your frontend turn into a massive unmaintainable monolith? If, like me, you’ve answered yes to any of those questions, this talk is for you! I’ll show you exactly how you can build a micro frontend architecture with Remix to solve those challenges.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
Remix is a web framework that gives you the simple mental model of a Multi-Page App (MPA) but the power and capabilities of a Single-Page App (SPA). One of the big challenges of SPAs is network management resulting in a great deal of indirection and buggy code. This is especially noticeable in application state which Remix completely eliminates, but it's also an issue in individual components that communicate with a single-purpose backend endpoint (like a combobox search for example).
In this talk, Kent will demonstrate how Remix enables you to build complex UI components that are connected to a backend in the simplest and most powerful way you've ever seen. Leaving you time to chill with your family or whatever else you do for fun.
Making JavaScript on WebAssembly Fast
JSNation Live 2021JSNation Live 2021
29 min
Making JavaScript on WebAssembly Fast
Top Content
JavaScript in the browser runs many times faster than it did two decades ago. And that happened because the browser vendors spent that time working on intensive performance optimizations in their JavaScript engines.Because of this optimization work, JavaScript is now running in many places besides the browser. But there are still some environments where the JS engines can’t apply those optimizations in the right way to make things fast.We’re working to solve this, beginning a whole new wave of JavaScript optimization work. We’re improving JavaScript performance for entirely different environments, where different rules apply. And this is possible because of WebAssembly. In this talk, I'll explain how this all works and what's coming next.
Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
As developers, we spend much of our time debugging apps - often code we didn't even write. Sadly, few developers have ever been taught how to approach debugging - it's something most of us learn through painful experience.  The good news is you _can_ learn how to debug effectively, and there's several key techniques and tools you can use for debugging JS and React apps.
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
Webpack in 5 Years?
JSNation 2022JSNation 2022
26 min
Webpack in 5 Years?
Top Content
What can we learn from the last 10 years for the next 5 years? Is there a future for Webpack? What do we need to do now?