WorkflowOtherOpen

Validate TOTP 2FA codes in n8n without credentials

This n8n workflow checks whether a six digit TOTP code is valid for a given secret, using only a code node and no saved credential. It is for developers building login or two factor checks in n8n who already store each user's TOTP secret in a database.

What it does

The TOTP VALIDATION code node computes the expected code from the secret and compares it with the code supplied, and an If node branches on the result. Example fields show the input format.

How to use it

Copy only the TOTP VALIDATION node into your workflow and change lines 39 and 40 to point at your secret and code values.

More in Other and the n8n workflow library.

Full text

Front matter
name: TOTP VALIDATION (WITHOUT CREATING CREDENTIAL)
description: Triggered manually or by an app event. Connects Code, Condition, Stop And Error. ## TOTP Validation with Function Node This template allows you to verify if a 6-digit TOTP code is valid using the corresponding TOTP secret. It can be used in an authentication system. ### Example usage: - You retrieve the user's TOTP secret from a database, then you want to verify if the 2FA code provided by the user is valid. ## Setup Guidelines You only need the "TOTP VALIDATION" node. You will need to modify lines 39 and 40 of the "TOTP VALIDATION" node with the correct values for your s
category: Automation
kind: Workflow
software: Code|Condition|Stop And Error

TOTP VALIDATION (WITHOUT CREATING CREDENTIAL)

Triggered manually or by an app event. Connects Code, Condition, Stop And Error. ## TOTP Validation with Function Node

This template allows you to verify if a 6-digit TOTP code is valid using the corresponding TOTP secret. It can be used in an authentication system.

Example usage:

  • You retrieve the user's TOTP secret from a database, then you want to verify if the 2FA code provided by the user is valid.

Setup Guidelines

You only need the "TOTP VALIDATION" node. You will need to modify lines 39 and 40 of the "TOTP VALIDATION" node with the correct values for your s

Steps

  • When clicking ‘Test workflow’ (manualTrigger)
  • TOTP VALIDATION (code)
  • IF CODE IS VALID (if)
  • Sticky Note (stickyNote)
  • EXAMPLE FIELDS (set)
  • Error Handler (stopAndError)

Import

Download the JSON from the GitHub source and import it in n8n (Workflows, Import from file).

Source and license

Source: https://github.com/Zie619/n8n-workflows/blob/main/Manual/0558_Manual_Stickynote_Automation_Triggered.md

Author: Zie619, n8n workflow collection. License: MIT.

Shown here with formatting for the web. Keep the author and license notice when you reuse it.

Related entries

There are more like this in the members library

The n8n workflow library holds 1,814 entries. Members can search all of them by meaning and read every one in full.