Skip to content

Commit ba8ea1d

Browse files
mergify[bot]vigneshshanmugamgithub-actions[bot]
authored
[8.16](backport #4444) add synthetics multi factor authentication docs (#4476)
* add synthetics multi factor authentication docs (#4444) * add synthetics multi factor authentication docs * apply suggestions from code review Co-authored-by: Emilio Alvarez Piñeiro <[email protected]> * Apply suggestions from code review Co-authored-by: Brandon Morelli <[email protected]> Co-authored-by: Colleen McGinnis <[email protected]> * Update docs/en/observability/synthetics-mfa.asciidoc Co-authored-by: Colleen McGinnis <[email protected]> --------- Co-authored-by: Emilio Alvarez Piñeiro <[email protected]> Co-authored-by: Brandon Morelli <[email protected]> Co-authored-by: Colleen McGinnis <[email protected]> (cherry picked from commit 704f88d) # Conflicts: # docs/en/serverless/serverless-observability.docnav.json # docs/en/serverless/synthetics/synthetics-command-reference.mdx * Delete docs/en/serverless directory --------- Co-authored-by: Vignesh Shanmugam <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 259a1c1 commit ba8ea1d

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

docs/en/observability/index.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ include::synthetics-command-reference.asciidoc[leveloffset=+3]
5656

5757
include::synthetics-configuration.asciidoc[leveloffset=+3]
5858

59+
include::synthetics-mfa.asciidoc[leveloffset=+3]
60+
5961
include::synthetics-settings.asciidoc[leveloffset=+3]
6062

6163
include::synthetics-roles.asciidoc[leveloffset=+3]

docs/en/observability/synthetics-command-reference.asciidoc

+23
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,26 @@ and you do _not_ include `--url` and `--auth`, all global locations managed by E
333333
However, you will not be able to push to these locations with your API key and will see an error:
334334
_You don't have permission to use Elastic managed global locations_. For more details, refer to the
335335
<<synthetics-troubleshooting-public-locations-disabled,troubleshooting docs>>.
336+
337+
[discrete]
338+
[[elastic-synthetics-totp-command]]
339+
= `@elastic/synthetics totp <secret>`
340+
341+
Generate a Time-based One-Time Password (TOTP) for multifactor authentication (MFA) in Synthetics.
342+
343+
[source, sh]
344+
----
345+
npx @elastic/synthetics totp <secret>
346+
npx @elastic/synthetics totp <secret> --issuer <string> --label <string>
347+
----
348+
349+
`<secret>`::
350+
The encoded secret key used to generate the TOTP.
351+
352+
`--issuer <string>`::
353+
354+
Name of the provider or service that is assocaited with the account.
355+
356+
`--label <string>`::
357+
358+
Identifier for the account. Defaults to `SyntheticsTOTP`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[[synthetics-mfa]]
2+
= Multi-factor Authentication (MFA) for browser monitors
3+
4+
++++
5+
<titleabbrev>Multi-factor Authentication</titleabbrev>
6+
++++
7+
8+
Multi-factor Authentication (MFA) adds an essential layer of security to
9+
applications login processes, protecting against unauthorized access. A very
10+
common use case in Synthetics is testing user journeys involving websites
11+
protected by MFA.
12+
13+
Synthetics supports testing websites secured by Time-based One-Time Password
14+
(TOTP), a common MFA method that provides short-lived one-time tokens to
15+
enhance security.
16+
17+
[discrete]
18+
== Configuring TOTP for MFA
19+
20+
To test a browser journey that uses TOTP for MFA, first configure the
21+
Synthetics authenticator token in the target application. To do this, generate a One-Time
22+
Password (OTP) using the Synthetics CLI; refer to <<elastic-synthetics-totp-command>>.
23+
24+
```sh
25+
npx @elastic/synthetics totp <secret>
26+
27+
// prints
28+
OTP Token: 123456
29+
```
30+
31+
[discrete]
32+
== Applying the TOTP Token in Browser Journeys
33+
34+
Once the Synthetics TOTP Authentication is configured in your application, you
35+
can now use the OTP token in the synthetics browser journeys using the `mfa`
36+
object imported from `@elastic/synthetics`.
37+
38+
```ts
39+
import { journey, step, mfa} from '@elastic/synthetics';
40+
41+
journey('MFA Test', ({ page, params }) => {
42+
step('Login using TOTP token', async () => {
43+
// login using username and pass and go to 2FA in next page
44+
const token = mfa.token(params.MFA_GH_SECRET);
45+
await page.getByPlaceholder("token-input").fill(token)
46+
});
47+
});
48+
```
49+
50+
For monitors created in the Synthetics UI using the Script editor, the `mfa` object can be accessed as shown below:
51+
52+
```ts
53+
step('Login using 2FA', async () => {
54+
const token = mfa.token(params.MFA_GH_SECRET);
55+
await page.getByPlaceholder("token-input").fill(token)
56+
});
57+
```
58+
59+
[NOTE]
60+
====
61+
`params.MFA_GH_SECRET` would be the encoded secret that was used for registering the Synthetics Authentication in your web application.
62+
====

0 commit comments

Comments
 (0)