> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/pam/administration/sessions/web.md).

# Web sessions

Register a web application as an asset so the solution opens it in a browser and types the credential for the user, with the session recorded.

## What this is and when to use it

A web session gives a user access to a web application — a firewall console, an appliance admin page, a SaaS portal — without ever handing them the password. The solution opens the application's login page in a controlled browser, fills in the stored credential, and records what happens next. The password stays in the vault; the user never sees it.

Use it for any system whose only administrative interface is a web page. What the user gets is a link they can click; what they do not get is the account.

{% hint style="danger" %}
Web access needs an **additional Windows machine**. No web session runs on the PAM server itself — that is a deliberate security boundary, not a limitation to be worked around. Without that machine, a Website asset can be registered but not connected to. The machine is a Windows publishing host; the Microsoft licensing it needs is covered in [Remote Desktop Services licensing](https://wiki.datadike.com/pam/deploy-operate/rds-licensing.md).
{% endhint %}

## Before you start

* A console role with access to the **Sysadmin** area.
* A **Windows Server 2022 or 2025** machine to run the browser, with **OpenSSH installed and running**.
* The **exact URL of the application's login screen** — not its home page, not a landing page that redirects.
* The credential the application actually expects, ready to register as a managed account.
* If you intend to use autofill: the HTML identifiers of the username field, the password field, and the login button, collected in advance from the page itself.
* If the application asks for a second factor (MFA) and login must be fully automatic: the account's second-factor **key**, obtained when the authenticator is registered in the application. See [Login with a second factor (MFA)](#login-with-a-second-factor-mfa).
* The folder of the asset tree the asset will be filed in.
* If the application is reached through a proxy or a broker gateway, which of the two it is. See [Proxy](https://wiki.datadike.com/pam/administration/connectivity/proxy.md).

## Steps

Open the application's login page in your own browser first, and keep it open. You will need it to read the field identifiers. Then start the registration:

1. In the console, open **Environment › Assets** and click **Create**.
2. In the platform selection window, scroll to the **Web** group and select **Website**.

The **Create** wizard opens with five stages: **Basic**, **Selector**, **Protocol**, **Accounts**, and **Other settings**.

### Basic

1. Fill in the **Name**. Follow a naming convention someone else can read, such as `FW-HQ-CONSOLE`.
2. Fill in the **URL** of the login screen, including the port when it is not the default one: `https://system.example.local:8443/login`. See the two warnings below.
3. Leave **Platform** as it comes, already set to **Website**.
4. In **Nodes**, choose the folder of the asset tree this asset is filed in. See [Folders and tags](https://wiki.datadike.com/pam/administration/assets/folders-and-tags.md).

{% hint style="warning" %}
**The URL and the port are not independent fields.** To change the port, edit it inside the **URL**; the **Protocol** section follows the change. Changing `https://system.example.local:8088/dashboard` to `https://system.example.local:8443/dashboard` makes the Protocol section show `8443` as well. Never edit the port in the Protocol section alone.
{% endhint %}

{% hint style="warning" %}
**The URL must point directly at the authentication screen.** Autofill and auditing both depend on it. A URL that lands on a home page, a marketing page, or anything that redirects before the login form appears will break the credential injection.
{% endhint %}

### Selector

1. In **Autofill**, pick the mode: **Disabled**, **Basic**, or **Script**. The three are described under *Autofill modes* below.
2. For **Basic**, fill in the **Username selector**, the **Password selector**, and the **Submit selector** of the login button. For **Script**, paste the JSON script into the **Script** field that appears.

### Protocol

1. Confirm the protocol is `http(s)` and check the port shown. It follows the URL entered under **Basic**.

Protocol settings are **inherited from the platform**. The gear icon next to the protocol shows them; to change them, edit the platform.

### Accounts

1. Click **Add** (or **Add account**) to register the credential the application itself expects: the real username and password used at that login screen.
2. Fill in the **Name**, which is how the credential is identified in the console.
3. Fill in the **Username** the application expects at its login screen.
4. Turn on **Privileged** if the account carries elevated rights in the application.
5. Leave **Secret type** on **Password**, and type the password. The eye icon shows what you typed; the refresh icon generates a password.
6. Leave **Active** enabled. If you add **Notes**, keep them free of secrets.
7. Click **Confirm**. Repeat for every credential that belongs to the same asset.

### Other settings

1. Under **Proxy** or **Gateway (Broker)**, select the path to the application. Choose **one of the two, never both**: once one is set, the other is hidden. Leave both empty when the application is reached directly.
2. Optionally add **Tags** for categorization.
3. Leave **Active** enabled so the asset is available.
4. Optionally add a **Comment**. Ordinary users see it when they hover over the asset in the asset tree of their access list, so it must never hold sensitive information.
5. Click **Confirm** to save the asset.

### Grant access

Registering the asset grants access to nobody. Until an authorization covers it, the asset exists and nobody can reach it.

1. Open **Policies › Authorization** and either edit an existing policy or create one.
2. Associate the users or groups with the new website, and save the policy. See [Authorizations](https://wiki.datadike.com/pam/administration/access/authorizations.md).

## Autofill modes

| Mode         | Use it when                                                                                                                    | What happens                                                                              |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
| **Disabled** | You only want the session audited                                                                                              | The user types the credential themselves. The solution records and monitors, nothing more |
| **Basic**    | The login is simple — username, password, and button on one screen                                                             | The solution locates the three elements by selector and fills them in                     |
| **Script**   | Authentication happens in stages — separate screens or sections for username and password, or the form sits inside an `iframe` | An ordered list of actions is executed, step by step                                      |

### Basic selectors

1. Open the login page in your browser.
2. Right-click the field and choose **Inspect**.
3. Read the identifier off the HTML for each of the three elements: username field, password field, login button.
4. Enter it in the corresponding selector field.

Prefer identifiers in this order:

1. `ID`
2. `NAME`
3. `XPath`

Typical values look like `id=username`, `name=password`, `id=login_button`. `XPath` is last because it describes a position in the page structure, and page structures change.

### Script mode

Selecting **Script** reveals a field for a JSON script. Each entry is one action, executed in the order given.

| Command        | What it does                                                                                                | `target`                                   | `value`                                                           |
| -------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ----------------------------------------------------------------- |
| `type`         | Types into a field                                                                                          | The field                                  | The text, with the variables below                                |
| `click`        | Clicks a button or link                                                                                     | The element                                | `""`                                                              |
| `code`         | Types the second-factor (MFA) code. See [Login with a second factor (MFA)](#login-with-a-second-factor-mfa) | The code field                             | `""`                                                              |
| `select_frame` | Switches into an `iframe`. `index=-1` returns to the main page                                              | `id=`, `name=` or `index=` of the `iframe` | `""`                                                              |
| `sleep`        | Waits a fixed time                                                                                          | Seconds, from 0 to 30                      | `""`                                                              |
| `wait`         | Waits for an element to appear, without acting on it. Linux isolated browser only                           | The element                                | `""`                                                              |
| `open`         | Navigates to another URL                                                                                    | `""`                                       | The `http` or `https` URL. Does not accept `{SECRET}` or `{TOTP}` |

The `target` says which element of the page the step uses, always in the form `prefix=value`:

| Prefix        | Example                        | Finds                                                   |
| ------------- | ------------------------------ | ------------------------------------------------------- |
| `id=`         | `id=username`                  | The element with that `id`                              |
| `name=`       | `name=password`                | The element with that `name`                            |
| `class_name=` | `class_name=btn-login`         | The element with that class                             |
| `css=`        | `css=input[type="password"]`   | The first element matching the CSS selector             |
| `xpath=`      | `xpath=//button[@id='signin']` | The element the XPath points to                         |
| `type=`       | `type=password`                | The field with that `type`. Linux isolated browser only |

Three variables carry the account's credential into the script: `{USERNAME}` for the username, `{SECRET}` for the password and `{TOTP}` for the current second-factor code. Never write a literal password into the script.

```json
[
  { "step": 1, "value": "",           "target": "id=iframe_id",     "command": "select_frame" },
  { "step": 2, "value": "{USERNAME}", "target": "name=username",    "command": "type" },
  { "step": 3, "value": "",           "target": "id=next_button",   "command": "click" },
  { "step": 4, "value": "",           "target": "5",                "command": "sleep" },
  { "step": 5, "value": "{SECRET}",   "target": "name=password",    "command": "type" },
  { "step": 6, "value": "",           "target": "id=submit_button", "command": "click" }
]
```

That script switches into the `iframe`, types the username, clicks **Next**, waits five seconds for the second screen to load, types the password, and submits. The `sleep` step is what makes a staged login work — without it the next `type` runs against a field that does not exist yet.

When you write your own script:

* Keep one object per step, each with the four attributes `step`, `value`, `target`, and `command`, in the same order every time. The script stays easy to read and to maintain.
* `value` is always present, even when empty (`""`), on `click` and `select_frame`.
* When the next screen is slow to load, add a `sleep` step with the number of seconds in `target`.
* When the form sits inside an `iframe`, the first step is `select_frame`, pointing at the identifier of the `iframe`.
* In an `XPath` selector, use single quotes inside the expression, as in `//*[@id='app']`. A double quote closes the JSON string and invalidates the script.
* In the Linux isolated browser, each step waits for its element to appear before acting, so `sleep` is only needed when the page reuses a field that already existed. On the Windows publishing host the element must exist at the moment of the step; there, `sleep` between screens is mandatory.

{% hint style="warning" %}
**In Script mode the script runs even without an account.** If the authorization grants access through the anonymous account, `{USERNAME}` and `{SECRET}` are empty and the script types blank fields. When one group of users must type its own credential and another needs automatic login, register two assets: one with autofill **Disabled** and another with **Script**.
{% endhint %}

### Login with a second factor (MFA)

Many applications ask, after the password, for a six-digit code from an authenticator app. The solution types that code too, in one of two ways:

* **With the OTP registered on the account:** the asset's account stores the second-factor key (the **OTP code** field; see [Web account OTP code](https://wiki.datadike.com/pam/administration/accounts/managed-accounts.md#web-account-otp-code)). On connection the current code is generated and typed with no user interaction. If fewer than three seconds remain before the code expires, the solution waits for the next one.
* **Without OTP on the account:** the `code` step opens a window in the session asking the user for the code, and the solution types it into the field.

Automatic code generation exists in the Linux isolated browser. On the Windows publishing host the `code` step always asks the user for the code.

Use the `code` command for the code step. It confirms the page reached the second-factor screen before typing, and picks between the account's OTP and asking the user on its own. The `{TOTP}` variable inside a `type` also works, but fails when the account has no OTP.

{% hint style="info" %}
The OTP stores the second factor's **key**, never a six-digit code. The key is shown when the second factor is registered in the application, as a QR code or as text ("secret key"). If the second factor is already registered only on someone's phone, register a second device in the application to obtain the key; there is no need to remove the first. Only time-based codes (TOTP) are accepted.
{% endhint %}

#### Example: single sign-on portal with three screens

A typical single sign-on portal, such as AWS IAM Identity Center (`https://<company>.awsapps.com/start`), asks for the username, then the password and then the MFA code, each on its own screen:

```json
[
  { "step": 1, "value": "{USERNAME}", "target": "css=input[type=\"text\"]",     "command": "type" },
  { "step": 2, "value": "",           "target": "css=button[type=\"submit\"]",  "command": "click" },
  { "step": 3, "value": "{SECRET}",   "target": "css=input[type=\"password\"]", "command": "type" },
  { "step": 4, "value": "",           "target": "css=button[type=\"submit\"]",  "command": "click" },
  { "step": 5, "value": "",           "target": "3",                            "command": "sleep" },
  { "step": 6, "value": "",           "target": "css=input[type=\"text\"]",     "command": "code" },
  { "step": 7, "value": "",           "target": "css=button[type=\"submit\"]",  "command": "click" }
]
```

The `sleep` in step 5 covers the switch from the password screen to the code screen: both have a submit button, and step 6 must find the field of the new screen. Quotes inside the CSS selectors are written as `\"` because the script is JSON. Use the example as a starting point and check the selectors on your own page: login screens differ from one provider to another, and sometimes from one version to the next.

To have nobody type credentials:

1. Register the account on the asset with the username, the password and the **OTP code**.
2. In the authorization, grant that account, not the anonymous account or the one typed by the user. See [Authorizations](https://wiki.datadike.com/pam/administration/access/authorizations.md).
3. Connect as one of the authorized users and confirm the session reaches the application's home page without any login screen.

## What you should see

The saved asset appears in the inventory under the **WEB** group, with the platform badge **Website** and the state `ACTIVE`. Its details show the protocol as `http(s)` on the port taken from the URL.

## How to verify it worked

Registration proves nothing on its own. Verify by connecting:

1. Sign in as a user the authorization covers — not as the administrator who created the asset. That is the only way to confirm the authorization is right.
2. Open the website from the device access list. The browser session should land on the application **already logged in**.
3. Confirm the session is listed in the audit trail with the account that was used.

Reading the result:

* It stops on the login page with the fields filled but not submitted: the button selector is wrong.
* It stops on the login page with the fields empty: the field selectors are wrong, or the URL is not the login page.
* The session works but is not recorded: the URL is bypassing the authentication screen.

## Common errors

| Symptom                                                                  | Cause                                                                                                                                                                   | Fix                                                                                                                                         |
| ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Connection fails immediately                                             | The application is not reachable over the configured network path: the Windows host that runs the session has no route to it, or the wrong proxy or gateway is selected | Place that host in a network able to reach the application, and check the **Proxy** or **Gateway (Broker)** chosen under **Other settings** |
| Session opens on the login page, nothing filled                          | Autofill is **Disabled**, or the URL does not land on the login form                                                                                                    | Set the mode to Basic or Script, and point the URL directly at the authentication screen                                                    |
| Fields fill but login never submits                                      | The login button selector is wrong                                                                                                                                      | Re-inspect the button and prefer its `ID` over an `XPath`                                                                                   |
| Username is typed, password field is never found                         | Staged login being handled in **Basic** mode                                                                                                                            | Switch to **Script** and add `select_frame` and `sleep` steps                                                                               |
| The script does nothing after an `XPath` step                            | Double quotes inside the `XPath` expression closed the JSON string                                                                                                      | Use single quotes inside the expression: `//*[@id='app']`                                                                                   |
| A window asks for the code although the account has OTP                  | The session used another account (the anonymous one or the one typed by the user), or the session runs on the Windows publishing host, which always asks for the code   | Grant in the authorization the account that has the OTP and connect with it                                                                 |
| The code is typed but the application rejects it                         | The stored key is not the one of the device registered in the application, or the clock of the server running the browser has drifted                                   | Register the authenticator again and store the new key; keep the clock synchronized by NTP                                                  |
| The script stops with "field not found in step N"                        | Step N's selector matches nothing on the screen, or the screen had not loaded yet                                                                                       | Inspect the field again; if the screen is slow, increase the `sleep` before the step                                                        |
| Users who should type their own credential see blank fields being filled | The asset is in **Script** mode and the session uses the anonymous account                                                                                              | Split into two assets: one **Disabled** and another with **Script**                                                                         |
| Port change has no effect                                                | The port was edited in the Protocol section but not in the URL                                                                                                          | Edit the port inside the **URL**, then confirm the Protocol section shows the same value                                                    |
| The asset exists but no user sees it                                     | No authorization covers it                                                                                                                                              | Create or edit a policy under **Policies › Authorization** with the users or groups                                                         |
| No web session starts at all                                             | No Windows machine, or OpenSSH not running on it                                                                                                                        | Provision the Windows Server 2022/2025 host and start OpenSSH                                                                               |

## Field reference

| Field                            | Meaning                                                                                                                                         |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**                         | Identifier inside the console. Use a readable convention. Required                                                                              |
| **URL**                          | The application's login page. Also determines the effective port. Required                                                                      |
| **Platform**                     | **Website**. Decides the asset's behaviour and protocol restrictions                                                                            |
| **Nodes**                        | The folder of the asset tree the asset is filed in. Used by authorizations, automations, and sync policies to target groups of assets. Required |
| **Selector**                     | Autofill mode: Disabled, Basic, or Script                                                                                                       |
| **Protocol**                     | `http(s)` plus the port. Follows the URL; may be inherited from the platform                                                                    |
| **Account › Name**               | How the credential is identified in the console. Required                                                                                       |
| **Account › Username**           | The username the application expects                                                                                                            |
| **Account › Privileged**         | Marks the credential as holding elevated rights                                                                                                 |
| **Account › Secret type**        | Set to **Password** for a website                                                                                                               |
| **Proxy** / **Gateway (Broker)** | The path to the application. Choose one, never both                                                                                             |
| **Tags**                         | Optional categorization of the asset                                                                                                            |
| **Active**                       | Must stay enabled for the asset to be available                                                                                                 |
| **Comment**                      | Informational, and visible to ordinary users in the asset tree. Do not put sensitive information here                                           |

## Related pages

* [Asset inventory](https://wiki.datadike.com/pam/administration/assets/inventory.md)
* [Managed accounts](https://wiki.datadike.com/pam/administration/accounts/managed-accounts.md)
* [Authorizations](https://wiki.datadike.com/pam/administration/access/authorizations.md)
* [Proxy](https://wiki.datadike.com/pam/administration/connectivity/proxy.md)
* [Remote Desktop Services licensing](https://wiki.datadike.com/pam/deploy-operate/rds-licensing.md)
