Skip to content
Open dashboard (opens in a new tab)

Authentication

Recorded logins

A recorded login is a browser login you perform once. NightVision saves the steps as a Playwright script and replays them at the start of every scan. It works with login forms, single sign-on redirects and one-time codes.

In the dashboard: Authentications

Open Authentications (opens in a new tab)

Recording happens on your machine, in a Chrome window the NightVision CLI opens. You can start it from the dashboard, which builds the command for you, or run the CLI directly.

  • Install the CLI and sign in with nightvision login. See Install the CLI.
  • Have a test account for the application. Use a dedicated scan account, not a real user’s.
  • Your machine must be able to reach the login page. The application does not have to be public to record a login.
  1. Select Authentications, then New authentication.

  2. Choose the Project.

  3. Under Authentication type, keep Recorded authentication (Playwright). Under How would you like to set this up?, keep Create new.

  4. Enter an Authentication name, an optional Description, and the Login URL, the page where the login starts. NightVision checks whether it can reach the page and tells you the result under the field. If it cannot, you can still record from your machine.

  5. Select Generate command.

  6. Copy the command from the macOS and Linux or Windows tab and run it in a terminal.

    The Create new authentication dialog showing the nightvision auth playwright create command, the three recording steps and a Waiting for your recording panel.
    The dashboard builds the record command and waits for the upload.
  7. A Chrome window opens on the login URL. Log in as you normally would, including any single sign-on redirect or one-time code.

  8. Once you are logged in, close the Chrome window. The CLI uploads the recording.

  9. The dialog changes from Waiting for your recording to Recording received. Select Configure MFA if the login used a one-time code (see MFA and TOTP), then Done.

The new authentication appears on the Authentications page. Assign it to an application to use it.

Terminal window
nightvision auth playwright create my-login https://app.example.com/login

The two arguments are the authentication name and the login URL. Chrome opens, you log in, you close the window, and the CLI uploads the script and prints a link to it in the dashboard.

Flag What it does
-d, --description Sets a description
-p, --project The project name. Without it the CLI uses the project you set with nightvision project set
-P, --project-id The project id, in place of the name
--save <path> Also writes the recorded Playwright file to a local path

Then scan with it:

Terminal window
nightvision scan my-app --auth my-login

The script is the list of steps: the pages visited, the fields filled and the buttons clicked. Every value you typed is replaced with a numbered placeholder, in the order you typed them:

page.goto("https://app.example.com/login")
page.get_by_label("Email").fill("{{0}}")
page.get_by_label("Password").fill("{{1}}")
page.get_by_role("button", name="Sign in").click()

The typed values are stored encrypted, apart from the script, and are filled back in only when a scan replays the login. NightVision never shows them again.

Open the authentication and select Script and settings to read the script. The line below it lists the placeholders and their line numbers.

The Script and settings tab of a recorded login with the Playwright script, an MFA configured chip, and the Details panel listing project, Login URL and multi-factor settings.
Script and settings: the recorded script on the left, the details on the right.
  • Start from the login page itself, not from a page that redirects to it.
  • Log in the way a user does, through the page. Each value you type becomes one placeholder.
  • Stop as soon as you are signed in. Clicks after that become steps every scan repeats.
  • If the login asks for a one-time code, type the current code while recording, then configure MFA so scans generate a fresh one.
  • Keep it short. A script holds up to 5,000 characters.

Open the authentication and select Run login check. It replays the login without scanning and reports whether the session is signed in. See Login check.

The Login history tab lists every scan and login check that used the authentication, with the login status of each. Select a row to open that run’s screenshots.

The Login history tab of a recorded login listing scans and login checks with a Login status and a Status column.
Login history. One run ended Not logged in; the rest completed the script.

The statuses are explained in Login statuses.

Re-record when the login flow changes, the password changes, or the latest login failed. Re-recording replaces the script and the stored values. The name, the project and the applications that use the authentication stay the same.

  1. Open the authentication and select Re-record. A failing login also shows Re-record login in its warning, on the authentication and on each application that uses it.

  2. Copy the command and run it in a terminal.

    The Re-record login dialog with the nightvision auth playwright update command ending in --script and a Waiting for your recording panel.
    Re-record login builds the update command for this authentication.
  3. Log in again in the Chrome window and close it.

  4. When the dialog shows Recording received, select Close. Scans log in with the new recording from their next run.

From the CLI:

Terminal window
nightvision auth playwright update my-login --script

If MFA is configured and the new recording changes the line that fills the one-time code, the MFA placeholder is cleared. Scans then run without a code until you pick the placeholder again.

For a small change, such as a renamed button, edit the script in the browser instead.

Select Edit on the authentication to change the name, the description or the Login URL. Changing the login URL rewrites the first page.goto() in the script to match. To record the login again at the new address, select Generate command in the same dialog.

From the CLI:

Flag on nightvision auth playwright update <name> What it does
-n, --name Renames the authentication
-d, --description Changes the description
-u, --url Sets a new login URL and records the login again there
-s, --script Records the login again at the current URL
--save <path> Also writes the new recording to a local path
-p, --project or -P, --project-id The project the authentication is in
Task Endpoint
Create from a script you already have POST /api/v1/credentials/script/ with name, project, script_first_url and script_content
Read, rename or replace the script GET and PUT /api/v1/credentials/{id}/
Delete DELETE /api/v1/credentials/{id}/

Stored values are never returned. Each comes back as its placeholder.