Skip to content

Commit f0be900

Browse files
mergify[bot]vigneshshanmugamgithub-actions[bot]bmorelli25
authored
[8.15](backport #4444) add synthetics multi factor authentication docs (#4474)
* 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 <95703246+emilioalvap@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Brandon Morelli <bmorelli25@gmail.com> Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update docs/en/observability/synthetics-mfa.asciidoc Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> --------- Co-authored-by: Emilio Alvarez Piñeiro <95703246+emilioalvap@users.noreply.github.com> Co-authored-by: Brandon Morelli <bmorelli25@gmail.com> Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> (cherry picked from commit 704f88d) # Conflicts: # docs/en/observability/index.asciidoc # docs/en/serverless/serverless-observability.docnav.json # docs/en/serverless/synthetics/synthetics-command-reference.mdx * Delete docs/en/serverless directory * actually that was easy --------- Co-authored-by: Vignesh Shanmugam <vignesh.shanmugam22@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: bmorelli25 <brandon.morelli@elastic.co>
1 parent 3dd991a commit f0be900

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

docs/en/observability/index.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ include::synthetics-command-reference.asciidoc[leveloffset=+2]
112112

113113
include::synthetics-configuration.asciidoc[leveloffset=+2]
114114

115+
include::synthetics-mfa.asciidoc[leveloffset=+2]
115116
include::synthetics-settings.asciidoc[leveloffset=+2]
116117

117118
include::synthetics-roles.asciidoc[leveloffset=+2]

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,26 @@ and you do _not_ include `--url` and `--auth`, all global locations managed by E
320320
However, you will not be able to push to these locations with your API key and will see an error:
321321
_You don't have permission to use Elastic managed global locations_. For more details, refer to the
322322
<<synthetics-troubleshooting-public-locations-disabled,troubleshooting docs>>.
323+
324+
[discrete]
325+
[[elastic-synthetics-totp-command]]
326+
= `@elastic/synthetics totp <secret>`
327+
328+
Generate a Time-based One-Time Password (TOTP) for multifactor authentication (MFA) in Synthetics.
329+
330+
[source, sh]
331+
----
332+
npx @elastic/synthetics totp <secret>
333+
npx @elastic/synthetics totp <secret> --issuer <string> --label <string>
334+
----
335+
336+
`<secret>`::
337+
The encoded secret key used to generate the TOTP.
338+
339+
`--issuer <string>`::
340+
341+
Name of the provider or service that is assocaited with the account.
342+
343+
`--label <string>`::
344+
345+
Identifier for the account. Defaults to `SyntheticsTOTP`
Lines changed: 62 additions & 0 deletions
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)