Skip to content

Commit 531d95f

Browse files
committed
add synthetics MFA
1 parent 6982933 commit 531d95f

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

solutions/observability/apps/multi-factor-authentication-mfa-for-browser-monitors.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,56 @@
22
mapped_urls:
33
- https://www.elastic.co/guide/en/observability/current/synthetics-mfa.html
44
- https://www.elastic.co/guide/en/serverless/current/observability-synthetics-mfa.html
5+
6+
navigation_title: "Multi-factor Authentication"
57
---
68

7-
# Multi-factor Authentication (MFA) for browser monitors
9+
# Multi-factor Authentication (MFA) for browser monitors [synthetics-mfa]
10+
11+
12+
Multi-factor Authentication (MFA) adds an essential layer of security to applications login processes, protecting against unauthorized access. A very common use case in Synthetics is testing user journeys involving websites protected by MFA.
13+
14+
Synthetics supports testing websites secured by Time-based One-Time Password (TOTP), a common MFA method that provides short-lived one-time tokens to enhance security.
15+
16+
17+
## Configuring TOTP for MFA [configuring_totp_for_mfa]
18+
19+
To test a browser journey that uses TOTP for MFA, first configure the Synthetics authenticator token in the target application. To do this, generate a One-Time Password (OTP) using the Synthetics CLI; refer to [`@elastic/synthetics totp <secret>`](../../../solutions/observability/apps/use-synthetics-cli.md).
20+
21+
```sh
22+
npx @elastic/synthetics totp <secret>
23+
24+
// prints
25+
OTP Token: 123456
26+
```
27+
28+
29+
## Applying the TOTP Token in Browser Journeys [applying_the_totp_token_in_browser_journeys]
30+
31+
Once the Synthetics TOTP Authentication is configured in your application, you can now use the OTP token in the synthetics browser journeys using the `mfa` object imported from `@elastic/synthetics`.
32+
33+
```ts
34+
import { journey, step, mfa} from '@elastic/synthetics';
35+
36+
journey('MFA Test', ({ page, params }) => {
37+
step('Login using TOTP token', async () => {
38+
// login using username and pass and go to 2FA in next page
39+
const token = mfa.totp(params.MFA_SECRET);
40+
await page.getByPlaceholder("token-input").fill(token)
41+
});
42+
});
43+
```
44+
45+
For monitors created in the Synthetics UI using the Script editor, the `mfa` object can be accessed as shown below:
846

9-
% What needs to be done: Align serverless/stateful
47+
```ts
48+
step('Login using 2FA', async () => {
49+
const token = mfa.totp(params.MFA_SECRET);
50+
await page.getByPlaceholder("token-input").fill(token)
51+
});
52+
```
1053

11-
% Use migrated content from existing pages that map to this page:
54+
::::{note}
55+
`params.MFA_SECRET` would be the encoded secret that was used for registering the Synthetics Authentication in your web application.
1256

13-
% - [ ] ./raw-migrated-files/observability-docs/observability/synthetics-mfa.md
14-
% - [ ] ./raw-migrated-files/docs-content/serverless/observability-synthetics-mfa.md
57+
::::

0 commit comments

Comments
 (0)