---
title: Security and authentication
project: Flow
version: 11.1
section: components
language: en
license: MIT
url: https://totaljs.es/docs/flow/11-1/components/security/
updated: 2026-11-20T06:50:57.962Z
---

# Security and authentication

> Components for confirmation codes, one-time passwords, request limits and OAuth 2.0.

Components for confirmation codes, one-time passwords, request limits and OAuth 2.0. This page holds the catalogue groups **Security**, **API**.

Each entry lists the inputs and outputs of the component, its main settings and the text of its readme. To add a component to a FlowStream, see [Download components](/flow/11-1/guides/download-components/).

## API

### confirmation-code.html · version 1

Type: `component`

Generates confirmation codes and verifies them.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `count` | `Number` | no | `3` | Count of attempts. |
| `type` | `String` | no | `pin` | Type. |
| `length` | `Number` | no | `4` | Length. |
| `expire` | `String` | no | `5 minutes` | Expiration. |
| `lock` | `String` | no |  | Lock. |
| `limit` | `Number` | no | `1` | Max. calls per lock. |

**Inputs:** `create` (Create), `verify` (Verify).  
**Outputs:** `output` (Output).

This component can help you with generating confirmation codes. Keep data structure for inputs according to the documentation below.

**`create` input/output**

__Create input__:

- `id {String}` identifier (email, phone number, identifier, etc.)
- `param {String}` a custom parameter

__Create output__:

- `success {Boolean}` determines if the code is verified or not accroding to its identifier
- `value {String}` a pin/code/token
- `param {String}` a custom parameter (it sends only if the value is true)
- `error {String}` (optional) a simple error identifier, it can contain:
	- `locked` the identifier is locked by the previous call

**`verify` input/output**

__Verify input__:

- `id {String}` identifier (email, phone number, identifier, etc.)
- `value {String}` a pin/code/token

__Verify output__:

- `success {Boolean}` determines if the code is verified or not accroding to its identifier
- `slots {Number}` free slots/attempts
- `error {String}` (optional) a simple error identifier, it can contain:
	- `invalid` the code is invalid
	- `404` identifier not found

---

**Settings**

- __Lock__ prevents overwriting of the code according to the identifier

### iplimiter.html · version 1

Type: `component`

Limits the number of requests per IP address.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `count` | `Number` | no | `1` | Max. limit. |
| `timeout` | `Number` | no | `5` | Timeout in seconds. |
| `path` | `String` | no | `ip` | Path to the IP address. |

**Inputs:** `input` (Request).  
**Outputs:** `output` (Allowed), `error` (Blocked).

This component limits the number of requests per IP address. The component first tries to obtain the IP address from the `$.controller`. If that doesn't work, it tries to load the IP address from the payload.

### oauth2.html · version 1

Type: `component`

Obtains an OAuth 2.0 access token from another service.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `urltoken` | `String` | no |  | Token URL. |
| `urlauthorize` | `String` | no |  | Authorize URL. |
| `variable` | `String` | no |  | Assign token to the global variable. |
| `clientid` | `String` | no |  | Client ID. |
| `clientsecret` | `String` | no |  | Client secret. |
| `scope` | `String` | no |  | Scope. |
| `accesstoken` | `String` | no |  | Access token. |

**Inputs:** none.  
**Outputs:** none.

This component can obtain OAuth 2.0 access token from 3rd party service.

### totp.html · version 1

Type: `component`

Generates TOTP secrets and verifies one-time passwords for two-factor authorization.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `issuer` | `String` | no | `Total.js` | Issuer. |
| `time` | `Number` | no | `30` | Time. |

**Inputs:** `generate` (Generate), `verify` (Verify).  
**Outputs:** `output` (Output).

**Time-Based One-Time Password Algorithm**

This component can generate a secret and verifies the code (generated via Authenticator app) as a one-time password for 2FA authorization.

- recommended mobile apps: __Google Authenticator__ or __Microsoft Authenticator__

---

__How does it work?__

First, a user must generate a secret via`generate` input in the authenticator app. Then, for verification of the one-time generated password, you need to use the second input `verify,` which needs user secrets.

**`generate` input/output**

__Input data__:

- `user {String}` email or user/account name without special characters

__Output data `object` with__:

- `secret {String}` a generated secret which you must store for the specific user
- `url {String}` an optimized url address for tokenization
- `qrcode {String}` a link to the picture with QR code

**`verify` input/outputs**

__Input data `object` with__:

- `secret {String}`

__Output data `object` with__:

- `success {Boolean}` determines if the password is valid or not
