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

Authentication

Headers and cookies

Use a header or cookie header authentication when the application accepts a fixed value instead of a login flow: a bearer token, an API key, or session cookies you already hold. NightVision attaches the values to every request of the scan. There is no login step, so there is nothing to record.

In the dashboard: Authentications

Open Authentications (opens in a new tab)

Pick a value that outlives the scan. A token that expires in fifteen minutes leaves most of the scan signed out. If the application issues short-lived tokens from an endpoint, request a fresh one before each scan, as in Authenticate an API in a pipeline. If it only issues short-lived browser sessions, use a recorded login instead.

  1. Select Authentications, then New authentication.
  2. Choose the Project.
  3. Under Authentication type, select Header authentication.
  4. Enter an Authentication name and an optional Description.
  5. Under Headers, enter a Header name and a Header value, for example Authorization and Bearer <token>. The value is masked as you type.
  6. Select Add another for each further header.
  7. Select Create.
The Create new authentication dialog with Header authentication selected and two headers, Authorization and X-Tenant, with masked values.
A header authentication with two headers. Values are masked.
  1. Select Authentications, then New authentication.
  2. Choose the Project.
  3. Under Authentication type, select Cookie header authentication.
  4. Enter an Authentication name and an optional Description.
  5. Under Cookies, enter a Cookie name and a Cookie value. Select Add another for each further cookie.
  6. Check the preview under This Authentication will add the following header. It shows the single Cookie header NightVision sends, with the values masked.
  7. Select Create.
The Create new authentication dialog with Cookie header authentication selected, one session_id cookie, and a preview of the Cookie header it adds.
A cookie header authentication. The preview shows the Cookie header scans send.

All the cookies go out together as one header, for example Cookie: session_id=...; csrf_token=....

The dashboard stores this as a header authentication that holds one Cookie header, so its type reads Header in the list. To change it later, select Update values and enter the whole cookie string as the new value of the Cookie header. A cookie authentication created with the CLI reads Cookie header and keeps one row per cookie. Both behave the same in a scan.

After you create either type, assign it to an application.

Open the authentication and select Stored values and settings. NightVision lists the header or cookie names. Each value reads Not shown, because stored values are encrypted and never displayed again.

The Stored values and settings tab of a header authentication listing Authorization and X-Tenant with their values not shown.
Stored headers show their names only.

To rotate a token or change the set:

  1. Select Update values.
  2. Enter a new value for the header or cookie you want to replace. Leave a value blank to keep the stored one.
  3. Add or remove rows as needed, then select Update.

Applications that use the authentication pick up the new values on their next scan.

  • Latest login reads No login flow. There is no login to check, so header and cookie authentications have no login status, no screenshots and no Run login check button.
  • The Runs tab lists the scans that used the authentication.
  • If the token is wrong or has expired, the scan still runs but the application answers as it would to a signed-out user. Watch for a scan that finds far fewer pages or endpoints than you expect, and check its coverage.

Create a header authentication with one -H per header, written as Name: value:

Terminal window
nightvision auth headers create my-api-token \
-H "Authorization: Bearer <token>" \
-H "X-Tenant: example-corp" \
--description "Service token for the payments API"

Create a cookie header authentication the same way. Each -H is one cookie, written as name: value:

Terminal window
nightvision auth cookies create my-session \
-H "session_id: <value>" \
-H "csrf_token: <value>"

Update either one by name. The headers or cookies you pass replace the stored set:

Terminal window
nightvision auth headers update my-api-token -H "Authorization: Bearer <new token>"
nightvision auth cookies update my-session -H "session_id: <new value>"
Flag What it does
-H, --headers One header or cookie. Repeat the flag for more. Required on create
-d, --description Sets the description
-n, --name On update, renames the authentication
-p, --project or -P, --project-id The project. Without it the CLI uses the project you set with nightvision project set

Then scan with it:

Terminal window
nightvision scan my-api --auth my-api-token
Task Endpoint
Create a header authentication POST /api/v1/credentials/header/ with project, name and headers, a list of {"name": ..., "value": ...}
Create a cookie header authentication POST /api/v1/credentials/cookie/ with project, name and cookie, a list of {"name": ..., "value": ...}
Read or update GET and PUT /api/v1/credentials/{id}/

A read never returns stored values. Each comes back as a placeholder, and sending that placeholder back on an update keeps the stored value.