# Introduction

The Twosense documentation contains information to help you deploy Twosense to your organization and troubleshoot any issues you may run into.

This documentation is organized by software component. To view documentation for a specific component of the Twosense product, switch from the dropdown at the top of the page. You can search all documentation at once using the search bar in the top-right of the page.


# System Requirements

### Windows Agent

* A supported 64-bit Windows version
  * Windows 10 version 1803 (OS build 17134) or later
  * Windows 11
* Dual-core processor
* 2GB RAM
* Domain joined (Active Directory or EntraID)
* Continuous internet connectivity

{% hint style="info" %}
In VDI environments, the Twosense agent can be installed onto a virtual machine.&#x20;
{% endhint %}

***

### Browser Extension (SSO Integration)

Chrome or Edge browser, latest stable version


# FAQ

### Privacy

**What data does the Twosense agent collect?**\
Twosense measures behavioral data such as typing cadence and mouse movements continuously throughout the day.

**Are my keystrokes being logged somewhere?**\
Keystrokes and the resulting characters entered are not collected, with no mechanism for a User, Administrator, or Twosense employee to see what has been typed. Our system collects on the "how" of typing, not the "what" that was typed.

**Does Twosense use my webcam or microphone?**\
No, Twosense does not use a webcam or a microphone, does not collect audio or visual data, nor require the hardware to be present.

**Does Twosense keep track of when I’m at my computer, or any other performance tracking?**\
Twosense is not productivity software. We only report a list of authentication events and whether or not the MFA challenge was successfully automated.

***

### Functionality

**How long does it take to start working?**\
Like any machine-learning system, it takes time before your unique behavior can be effectively modeled. For most users, some behavioral signals will have been learned within a day or two, with all users complete in under two weeks under normal usage.

**Can users be locked out of applications if Twosense goes down?**\
If Twosense’s cloud service is unavailable, all users will be directed to traditional MFA workflows (the same ones they are using today.)

**Does Twosense need sensitive access to the IdP or SSO?**\
No administrative access or keys are required. Twosense functions as a multifactor provider, which an Administrator will need to initially configure. From that point onwards, no further access is needed.

**Can Twosense be rolled out to a specific group of users?**\
Yes. Twosense is configured as an MFA factor that gets added to a policy. That policy can then be applied to any group of users.

**Can Twosense be used for remote employees?**\
Yes. Twosense is designed to be used for both secure facilities and remote agents.


# Anti-Virus Configuration

Learn how to explicitly allow Twosense software in your anti-virus solution to avoid issues.

## Anti-Virus Configuration

Due to the deeply integrated nature of the Twosense agent software, heuristic analysis from anti-virus engines may erroneously classify components of it as malware. If this happens, the anti-virus may attempt to quarantine the software and cause issues with the machine.

If your organization uses an endpoint protection solution or other form of anti-virus, please allow-list the following paths to prevent issues. Refer to your vendor's documentation on how to properly exempt paths from detection and quarantine.

* `C:\Program Files\TWOSENSE.AI\*`
* `C:\Windows\system32\drivers\kbfiltr.Sys`
  * This driver is a keyboard filter which allows the Twosense agent to capture typing behavior during Windows login. To verify its authenticity, you may check the digital signature — it should be signed by Microsoft.

## Network and Firewall Configuration

Outgoing connections to the following hosts should be allow-listed. Depending on your use case, you may be provided a more specific list of hostnames by your account manager.

* `api.twosense.ai`
* `apiv2.twosense.ai`
* `endpoint-management.twosense.ai`
* `app.twosense.ai`
* `webapi.twosense.ai`
* `manager-approval.twosense.ai`
* `sentry.twosense.ai`
* `o386114.ingest.sentry.io`
* `logs.us-east-1.amazonaws.com`
* `monitoring.us-east-1.amazonaws.com`
* `api.mixpanel.com`
* `radius.twosense.ai`


# Diagnostic Tool

If you reach out to Twosense for support, you may be asked to run the Twosense Diagnostic Tool. It is a PowerShell script that runs a suite of self-tests, collects basic information about the system (such as OS version, domain-joined status, etc.), and copies logs from installed Twosense software to a single zip file that can be sent back to Twosense for further investigation.

To run the tool, follow these steps on the machine that is experiencing the issue:

1. If possible, sign in as the user experiencing the issue.
2. Open a new PowerShell window <mark style="color:yellow;">**as administrator**</mark>.
3. Navigate to a directory where you want the diagnostic information to be saved (such as the desktop, for example).
4. Paste the following one-liner into the window and run it:

```powershell
Set-ExecutionPolicy RemoteSigned -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://twosense-public.s3.amazonaws.com/TwosenseDiagnosticTool.ps1'))
```

{% hint style="info" %}
If you wish to inspect the contents or verify the integrity of the script before execution, you can download it directly from the URL above. The script is digitally signed by Twosense; you may verify this under **File Properties -> Digital Signatures**.\
\
![](/files/Do9ME1SIyeE8gYntQBUZ)
{% endhint %}

Once the diagnostic tool is finished, it will offer to send the information to the Twosense team. After entering your details, the diagnostic information will automatically be sent to us for further inspection. If you're having trouble with the automatic upload process, you can attach the generated zip file to an email instead.


# Introduction

Twosense can be integrated into an IdP using either a deployed browser extension or by embedding it directly in your login page using the Twosense SDK. This documentation provides requirements, guides, and troubleshooting info to make your Twosense deployment as smooth as possible.

If you are just getting started, visit the guide for your preferred method of deployment:

* [Extension + PingFederate Integration Guide](/browser-extension-sdk/browser-extension/ping-integration)
* [SDK + PingFederate Integration Guide](/browser-extension-sdk/sdk/ping-integration)


# Extension + Delinea Integration Guide

### What You'll Need to do

There are two main steps you’ll need to follow to complete the deployment. Total time is usually under 30 minutes.

* Install the Twosense browser extension into Chrome or Edge for all users that will be utilizing Twosense as a factor.
* Configure Secret Server to use Twosense as an MFA factor.

***

### Prerequisites

* A Secret Server or Secret Server Cloud instance. If you don't have one, Delinea offers free trials [here](https://thycotic.com/products/secret-server/start-a-trial/).
* An account or active trial with Twosense. Please contact us [here](https://www.twosense.ai/demo) to obtain a 30-day trial if you don’t have one already.
* The **API Hostname**, **Integration Key**, and **Secret Key** provided by your Twosense account manager.

***

### Step-by-step

1. Edit the application settings configuration file.\
   This is on the web application server and in a default installation would be named\
   `C:\inetput\wwwroot\SecretServer\web-appSettings.config`
2. The file is an XML configuration file.\
   To enable the TwoSense integration add the following line somewhere between `<appSetting>` and `</appSetting>`:\
   \
   `<add key="EnableTwosense" value="true" />`\
   \
   The new file should look something like this (assuming no other edits have been made in the past)\
   \
   `<?xml version="1.0" encoding="utf-8" ?>`\
   `<appSettings>`\
   `<add key="EnableTwosense" value="true" />`\
   `</appSettings>`
3. **Save** the configuration file.
4. Run an **IISReset** on the server to restart the application with the new setting.
5. Log in to Secret Server and navigate to **Admin** -> **Configuration**
6. On the ‘Login’ tab you will now see an option for **Enable TWOSENSE.AI Integration**, it will be defaulted to ‘**No**’.
7. **Edit** the login configuration page.
8. Check the box next to **Enable TWOSENSE.AI Integration**.
9. An additional configuration option will appear. Add the **API Hostname**, **Integration Key**, and **Secret Key** provided by your Twosense account manager.
10. The Twosense browser extension will begin building user profiles and automating MFA challenges. Your organization’s dashboard at <https://app.twosense.ai/> will show progress as the machine learning models improve and MFA challenges are automated


# Extension + OneLogin Integration Guide

### What You'll Need to do

There are two main steps you’ll need to follow to complete the deployment. Total time is usually under 30 minutes.

* Install the Twosense browser extension into Chrome or Edge for all users that will be utilizing Twosense as a factor.
* Configure Twosense as a factor in OneLogin and apply the policy to users.

***

### Prerequisites

* A OneLogin organization. If you don't already have one, you can get a free account at <https://www.onelogin.com/free-trial>
* An account or active trial with Twosense. Please contact us [here](https://www.twosense.ai/demo) to obtain a 30-day trial if you don’t have one already.
* The **Hostname**, **Port Number**, and **Shared Secret** provided by your Twosense account manager.

***

### Step-by-step

Add Twosense as a RADIUS factor:

1. Click “**New Auth Factor**” in the upper right corner\
   ![OneLogin1](https://www.twosense.ai/hs-fs/hubfs/OneLogin1.png?width=1853\&name=OneLogin1.png)
2. Select "**RADIUS**" as the new factor type:\
   ![OneLogin2](https://www.twosense.ai/hs-fs/hubfs/OneLogin2.png?width=1858\&name=OneLogin2.png)
3. Under "User Description" name the new factor **TWOSENSE**.\
   Note: this value must be exactly "TWOSENSE" for the integration to function properly.\
   ![OneLogin3](https://www.twosense.ai/hs-fs/hubfs/OneLogin3.png?width=1861\&name=OneLogin3.png)
4. Use the **Hostname**, **Port Number**, and **Shared Secret** provided by Twosense for this step.\
   ![OneLogin4](https://www.twosense.ai/hs-fs/hubfs/OneLogin4.png?width=1857\&name=OneLogin4.png)
5. Navigate to **Security > Policies**, select the policy you want to add Twosense to, and enable it as an OTP Auth factor:\
   ![OneLogin5](https://www.twosense.ai/hs-fs/hubfs/OneLogin5.png?width=1855\&name=OneLogin5.png)
6. Ensure that the policy is applied to “All users” of this policy, not “Administrator Only.”\
   ![OneLogin6](https://www.twosense.ai/hs-fs/hubfs/OneLogin6.png?width=1854\&name=OneLogin6.png)
7. **Save** the changes made to the policy.

{% hint style="info" %}
**NOTE**: Users never need to manually choose the TWOSENSE factor. If a user has the Twosense browser extension installed and belongs to a Policy with Twosense as a factor, each time they pass an MFA check the Twosense factor will automatically be prioritized for their next authentication.
{% endhint %}


# Extension + Okta Integration Guide

### What You'll Need to do

There are two main steps you’ll need to follow to complete the deployment. Total time is usually under 30 minutes.

* Download the On-Prem MFA Agent from the Okta administrative dashboard.
* Install the On-Prem MFA Agent. Configure the agent with the values provided by your Twosense account manager.

***

### Prerequisites

* An Okta Org. If you don't already have one, you can get a free account at <https://developer.okta.com/>
* An account or active trial with Twosense. Please contact us [here](https://www.twosense.ai/demo) to obtain a 30-day trial if you don’t have one already.
* You will need an Okta account with organization level privileges to install the Okta On-Prem MFA Agent.
* Provide your Twosense account manager the IP address of the server that will be running the Okta On-Prem MFA Agent.
* The **Radius host**, **port**, and **shared secret** provided by your Twosense account manager.

***

### Step-by-step

1. Log in to your Okta instance with an administrator account.
2. Navigate to **Security** → **Multifactor**, then select **On-Prem MFA** in the navigation menu.
3. Click **Add New Agent**.
4. Use the **Download the agent** link provided in this window to download the On-Prem MFA agent. Make note of the Instance ID provided to you. It will be used during the installation.
5. Run the downloaded agent on your Microsoft Windows server. You may need to adjust IE security settings to allow interaction with the Okta website during this process. Follow the step-by-step installation until it is completed.
6. Once the installation is complete, you should edit the **On-Prem Multifactor Authentication Settings** within the same page where you downloaded the agent. The following settings will need to be configured:
   * Provider username format: Okta username
   * Hostname: Provided by your Twosense account manager
   * Authentication Port: Provided by your Twosense account manager
   * Shared Secret: Provided by your Twosense account manager


# Extension + PingFederate Integration Guide

## System Requirements

* For Twosense to work properly, service providers must be configured to receive SAML responses as POST, not GET.

## Introduction

Use this guide to add Twosense MFA to your PingFederate SSO authentication flow. The following configuration steps are required:

* [Create RADIUS Password Credential Validator](#create-radius-password-credential-validator)
* [Create Twosense MFA IdP Adapter](#create-twosense-mfa-idp-adapter)
* [Modify the primary authentication adapter to return the userSid](#modify-the-primary-authentication-adapter-to-return-the-usersid)
* [Modify the primary authentication HTML form](#modify-the-primary-authentication-html-form)
* [Create HTTP Header Authentication Selector](#create-http-header-authentication-selector)
* [Create Authentication Policy](#create-authentication-policy)

## Create RADIUS Password Credential Validator

1. Navigate to **SYSTEM** and select **Password Credential Validators**.
2. Click **Create New Instance**.
3. In the **Type** tab, set the following:
   * *Instance Name*: **Twosense MFA RADIUS PCV**
   * *Instance ID*: **TwosenseMfaRadiusPcv**
   * *Type*: **RADIUS Username Password Credential Validator**
   * Click **Next**.
4. In the **Instance Configuration** tab, click **Add a new row to 'RADIUS Servers'**, and set the following:
   * *Hostname*: **radius.twosense.ai**
   * *Authentication Port*: **{Provided by Twosense}**
   * *Authentication Protocol*: **PAP**
   * *Shared Secret*: **{Provided by Twosense}**
   * Click **Update**.
   * Click **Next**.
5. In the **Extended Contract** tab, click **Next**.
6. Review the **Summary** tab, and click **Save**.

## Create Twosense MFA IdP Adapter

This adapter will be used by the Twosense browser extension to automate MFA requests.

1. Copy the `html.form.twosense.mfa.html` and `html.form.twosense.challenge.html` files from the setup package to your PingFederate instance under `pingfederate/server/default/conf/template/`.
2. Navigate to **AUTHENTICATION** and select **IdP Adapters**.
3. Click **Create New Instance**.
4. In the **Type** tab, set the following:
   * *Instance Name*: **Twosense MFA Form**
   * *Instance ID*: **TwosenseMfaForm**
   * *Type*: **HTML Form IdP Adapter**
   * Click **Next**.
5. In the **IdP Adapter** tab, under **Password Credential Validator Instance**, click **Add a new row to 'Credential Validators'**:
   * Select **Twosense MFA RADIUS PCV**
   * Click **Update**.
   * Set the following fields:
     * *Challenge Retries*: **1**
     * Click **Show Advanced Fields**.
     * *Login Template*: **html.form.twosense.mfa.html**
     * *Login Challenge Template*: **html.form.twosense.challenge.html**
     * *Allow Username Edits During Chaining*: **true**
     * *Fail Authentication on Account Lockout*: **true**
     * Click **Next**.
6. In the **Extended Contract** tab, click **Next**.
7. In the **Adapter Attributes** tab, check the **Pseudonym** checkbox for the **username** attribute, and click **Next**.
8. In the **Adapter Contract Mapping** tab, click **Configure Adapter Contract**.
   1. In the **Attribute Sources & User Lookup** tab, click **Next**.
   2. In the **Adapter Contract Fulfillment** tab, click **Next**.
   3. In the **Issuance Criteria** tab, click **Next**.
   4. In the **Summary** tab, click **Done**.
   5. Click **Next**.
9. Review the **Summary** tab, and click **Save**.

## Modify the primary authentication adapter to return the userSid

The Twosense MFA adapter requires the user's `objectSid` attribute. In order to do this, we need to extend the contract of the primary login form IdP adapter.

1. Navigate to **AUTHENTICATION** and select **IdP Adapters**.
2. Click on the IdP adapter of your primary login HTML form.
3. In the **Summary** tab, click **Extend Contract**.
   1. Under **Extend the Contract**, add the **objectSid** attribute.
   2. Navigate back to the **Summary** tab.
4. In the **Summary** tab, click **Attribute Sources & User Lookup**.
   1. In the **Attribute Source & User Lookup** tab, click **Add Attribute Source**.
      1. In the **Data Store** tab, set the following:
         * *ATTRIBUTE SOURCE ID*: **ActiveDirectory** (or another descriptive name)
         * *ATTRIBUTE SOURCE DESCRIPTION*: **Active Directory** (or another descriptive name)
         * *ACTIVE DATA STORE*: **{Your Active Directory Datastore}**
         * Click **Next**.
      2. In the **LDAP Directory Search** tab, set the following:
         * *BASE DN*: **{Your Active Directory Search Base DN}**
         * *Attributes to return from search*: **objectSid**
         * Click **Next**.
      3. In the **LDAP Binary Attribute Encoding Types** tab, select **SID** as the *Attribute Encoding Type* for *objectSID*, and click **Next**.
      4. In the **LDAP Filter** tab, set **FILTER** to **sAMAccountName=${username}**, click **Next**.
      5. In the **Summary** tab, click **Done**.
   2. In the **Attribute Source & User Lookup** tab, click **Next**.
   3. In the **Adapter Contract Fulfillment** tab, for **objectSid**:
      * Select **LDAP (Active Directory)** as the *Source*.
      * Select **objectSid** as the *Value*.
      * Click **Next**.
   4. In the **Issuance Criteria** tab, click **Next**.
   5. In the **Summary** tab, click **Done**.
5. In the **Adapter Contract Mapping** tab, click **Save**.

## Modify the primary authentication HTML form

The Twosense browser extension detects the presence of the primary login form by looking for a specific attribute in the HTML form. In order to do this, we need to modify the primary login form.

1. Navigate to **AUTHENTICATION** and select **IdP Adapters**.
2. Click on the IdP adapter of your primary login HTML form.
3. Find the name of the HTML form file by looking for the **Login Template** field in the **Summary** tab. The default value is `html.form.login.template.html`.
4. Find the file on your PingFederate instance under `pingfederate/server/default/conf/template/`.
5. Modify the HTML form to include the following attribute in the `<form>` tag `data-twosense-id="primary-login-form"`. The following is an example of a modified HTML form:

   ```html
   <form method="post" action="$url" autocomplete="off" data-twosense-id="primary-login-form">
   ```

## Create HTTP Header Authentication Selector

This selector will be used in the authentication policy to determine if the Twosense browser extension is active during the authentication flow.

1. Navigate to **AUTHENTICATION** and select **Selectors**.
2. Click **Create New Instance**.
3. In the **Type** tab, set the following:
   * *Instance Name*: **Twosense HTTP Header Selector**
   * *Instance ID*: **TwosenseHttpHeaderSelector**
   * *Type*: **HTTP Header Authentication Selector**
   * Click **Next**.
4. In the **Authentication Selector** tab, click **Add a new row to 'Results'**.
   * Set **Match Expression** to **`*`**, click **Update**.
   * Set **Header Name** to **X-Twosense-Extension**.
   * Uncheck **Case-Sensitive Matching**.
   * Click **Next**.
5. In the **Summary** tab, click **Save**.

## Create Authentication Policy

You can create a new authentication policy, or modify an existing one. These instructions will assume you are creating a new policy.

1. Navigate to **AUTHENTICATION** and select **Policies**.
2. Click **Add Policy**.
3. Set **Name** to **Twosense MFA Policy** or another descriptive name.
4. Under **Policy**, select any SP connection Selector you wish to use.
5. Under **NO**, click **Continue**.
6. Under **YES**, select your ***primary login HTML form IdP adapter***.
   1. Under **FAIL**, select **DONE**.
   2. Under **SUCCESS**, select **Twosense HTTP Header Selector**.
      1. Under **NO**, select your ***manual MFA IdP adapter*** (e.g., Duo).
      2. Under **YES**, select your ***Twosense MFA Form***.
      3. Click **Options**, and in the **Incoming User ID** form:
         * Set **Attribute** to **objectSid**.
         * Check **User ID Authenticated**.
         * Click **Done**.
   3. Under **SUCCESS** for the Twosense and manual MFA IdP adapters, select the appropriate policy contract.
   4. Under **FAIL**, select the action you wish to occur when communication between PingFederate and Twosense fails.
   5. Configure the **Rules** for the **Twosense MFA Form** adapter according to the table in the section below.
7. Click **Done**.
8. In the **Policies** tab, click **Save**.

### Twosense MFA Form Adapter Rules

The Twosense adapter will set the `policy.action` attribute to different values for different outcomes. The following table lists the possible values and their meaning. Use these values to create rules to fit your organization's needs.

| **`policy.action` Value** | **Outcome**                                                                                                          |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `no-agent`                | The Twosense agent was not detected on the client machine.                                                           |
| `twosense-client-error`   | An internal error occurred in the Twosense browser extension.                                                        |
| `challenge`               | The user was not authenticated (i.e., due to a low trust score) and should be presented an additional MFA challenge. |

For example, here's how you can customize your policy with rules based on the outcome:

![](/files/FPlQhIPvnpbL6UPuMMLT)

Then you can use these results to determine the next steps in your policy:

![](/files/fuM3dpyXSAWynUTVOcZY)


# SDK + PingFederate Integration Guide

## SDK + PingFederate Integration Guide

### Introduction

Use this guide to add Twosense MFA to your PingFederate SSO authentication flow.

### Setup Prerequisites

You will need the following items to proceed.

* Twosense Integration Package (your Twosense contact will provide this to you)
* Your organization's IKEY and SKEY
* Ability to add a browser group policy for managed devices
* PingFederate installation directory read/write access
* PingFederate admin console access
* An existing Active Directory data store configured in PingFederate

### Functional Requirements

* For Twosense to work properly, service providers must be configured to receive SAML responses as POST, not GET.

### Add Twosense Assets

Your Twosense contact will provide an integration package as a zip file. In this package there is a directory named `template`. Copy the **contents** of this directory to the `/server/default/conf/template` directory of your PingFederate installation.

After copying, the directory structure should look like this:

```
📁 server/
└── 📁 default/
    └── 📁 conf/
        └── 📁 template/
            ├── 📄 html.form.twosense.mfa.embedded.html
            |-- 📄 html.form.twosense.session.embedded.html
            ├── 📄 html.form.twosense.challenge.html
            └── 📁 assets/
                └── 📁 scripts/
                    ├── 📄 twosense-sw.js
                    └── 📄 twosense-client.js
```

### Install PingFederate Adapter

The integration package will also contain a file named `pf-twosense-adapter.jar`. Copy this file to your PingFederate installation's `/server/default/deploy/` directory, then restart PingFederate to load the adapter.

### Allow Twosense Resources

You will need to make some additional changes to your Ping configuration to allow the Twosense-related resources to load properly.

#### Allow Service Worker

The Twosense integration utilizes a service worker to perform MFA. To ensure it works properly, you must add the following lines to your PingFederate config's `/server/default/data/config-store/response-header-runtime-config.xml` file, inside of the `<con:config>` element:

```xml
<!-- Add inside the <con:config> element -->
<con:map name="Service-Worker-Allowed">
    <con:item name="value">/</con:item>
    <con:item name="include-patterns">*.js</con:item>
</con:map>
```

Once this change is made, the Ping service must be restarted for it to take effect.

#### Update Content Security Policy

If you have a custom content security policy, ensure that these directives are allowed:

* `img-src data:`
* `style-src 'self' 'unsafe-inline' *.googleapis.com`
* `worker-src 'self'`
* `connect-src 'self' http://127.0.0.1:27367 *.twosense.ai *.mixpanel.com`
* `script-src 'self' 'unsafe-inline' data:`
* `child-src 'self' data:`
* `font-src 'self' fonts.gstatic.com`

For example, here is a policy which will allow all the resources necessary for the Twosense SDK to work:

{% code overflow="wrap" %}

```
default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline' *.googleapis.com; script-src 'self' 'unsafe-inline' data:; child-src 'self' data:; connect-src 'self' http://127.0.0.1:27367 *.twosense.ai *.mixpanel.com; font-src 'self' fonts.gstatic.com
```

{% endcode %}

Note that your CSP may look different based on your situation; this is a minimal example.

If you are experiencing any additional CSP-related errors after these changes, please reach out to Twosense support.

#### Allow Local Network Access

{% hint style="warning" %}
If you use other Chromium-based browsers (such as Microsoft Edge) in your organization, you will need to repeat these steps for those browsers.
{% endhint %}

The Twosense SDK uses local requests to communicate with the Windows agent, and starting with Chrome version 142 this is automatically blocked unless explicitly allowed by the user or via Group Policy. In order to allow this behavior, you will need to add a policy exception for your PingFederate domain.

Use the [`LocalNetworkAccessAllowedForUrls`](https://chromeenterprise.google/policies/#LocalNetworkAccessAllowedForUrls) policy to grant the Twosense SDK service worker local network access. For example, if your PingFederate instance is hosted at `https://auth.example.com:9031`, you would add the following to the list of allowed URLs:

```
https://auth.example.com:9031/assets/scripts/twosense-sw.js
```

## Twosense MFA Adapter Configuration

### Create Twosense IdP Adapter

1. Navigate to **AUTHENTICATION** and select **IdP Adapters**.
2. Click **Create New Instance**.
3. In the **Type** tab, set the following:
   * *Instance Name*: **Twosense MFA**
   * *Instance ID*: **TwosenseMfaForm**
   * *Type*: **Twosense IdP Adapter**
   * Click **Next**.
4. In the fields labeled **Twosense IKEY** and **Twosense SKEY**, enter the values provided by your Twosense contact. If you do not have these values, please reach out to Twosense support.
5. If you require additional configuration options, such as proxy settings, press **Show Advanced Fields** and configure as needed.
6. Click **Next**.
7. Press **Test Connection** to verify connectivity to the Twosense service, then click **Next**.
8. In the **Extended Contract** tab, click **Next**.
9. In the **Adapter Attributes** tab, check the **Pseudonym** checkbox for the **result** attribute, and click **Next**.
10. In the **Adapter Contract Mapping** tab, click **Next**.
11. Review the **Summary** tab, and click **Save**.

### Modify the primary authentication adapter to return the userSid

The Twosense MFA adapter requires the user's `objectSid` attribute. In order to do this, we need to extend the contract of the primary login form IdP adapter.

1. Navigate to **AUTHENTICATION** and select **IdP Adapters**.
2. Click on the IdP adapter of your primary login HTML form.
3. In the **Summary** tab, click **Extend Contract**.
   1. Under **Extend the Contract**, add the **objectSid** attribute.
   2. Navigate back to the **Summary** tab.
4. In the **Summary** tab, click **Attribute Sources & User Lookup**.
   1. In the **Attribute Source & User Lookup** tab, click **Add Attribute Source**.
      1. In the **Data Store** tab, set the following:
         * *ATTRIBUTE SOURCE ID*: **ActiveDirectory** (or another descriptive name)
         * *ATTRIBUTE SOURCE DESCRIPTION*: **Active Directory** (or another descriptive name)
         * *ACTIVE DATA STORE*: **{Your Active Directory Datastore}**
         * Click **Next**.
      2. In the **LDAP Directory Search** tab, set the following:
         * *BASE DN*: **{Your Active Directory Search Base DN}**
         * *Attributes to return from search*: **objectSid**
         * Click **Next**.
      3. In the **LDAP Binary Attribute Encoding Types** tab, select **SID** as the *Attribute Encoding Type* for *objectSID*, and click **Next**.
      4. In the **LDAP Filter** tab, set **FILTER** to **sAMAccountName=${username}**, click **Next**.
      5. In the **Summary** tab, click **Done**.
   2. In the **Attribute Source & User Lookup** tab, click **Next**.
   3. In the **Adapter Contract Fulfillment** tab, for **objectSid**:
      * Select **LDAP (Active Directory)** as the *Source*.
      * Select **objectSid** as the *Value*.
      * Click **Next**.
   4. In the **Issuance Criteria** tab, click **Next**.
   5. In the **Summary** tab, click **Done**.
5. In the **Adapter Contract Mapping** tab, click **Save**.

### Embed Twosense Client in the primary authentication HTML template

The Twosense SDK detects the presence of the primary login form by looking for a specific attribute in the HTML form. In order for this detection to work, we need to modify the primary login form.

1. Navigate to **AUTHENTICATION** and select **IdP Adapters**.
2. Click on the IdP adapter of your primary login HTML form.
3. Find the name of the HTML form file by looking for the **Login Template** field in the **Summary** tab. The default value is `html.form.login.template.html`.
4. Find the file on your PingFederate instance under `pingfederate/server/default/conf/template/`.
5. Modify the HTML form to include the following attribute in the `<form>` tag `data-twosense-id="primary-login-form"`. The following is an example of a modified HTML form:

{% code overflow="wrap" %}

```html
<form method="post" action="$url" autocomplete="off" data-twosense-id="primary-login-form">
```

{% endcode %}

6. At the bottom of the template, directly before the closing `</body>` tag, add the following lines:

{% code overflow="wrap" %}

```html
<script
  src="/assets/scripts/twosense-client.js"
  data-sw-path="/assets/scripts/twosense-sw.js">
</script>
```

{% endcode %}

{% hint style="warning" %}
You will need to embed the Twosense client script on each primary login form template where you want Twosense to be active.

Please note that the location of this snippet matters; it **must** be added before the closing `</body>` tag, not in `<head>` or elsewhere.
{% endhint %}

### Create Authentication Policy

You can create a new authentication policy, or modify an existing one. These instructions will assume you are creating a new policy.

1. Navigate to **AUTHENTICATION** and select **Policies**.
2. Click **Add Policy**.
3. Set **Name** to **Twosense MFA Policy** or another descriptive name.
4. Under **Policy**, select any SP connection Selector you wish to use.
5. Under **NO**, click **Continue**.
6. Under **YES**, select your ***primary login HTML form IdP adapter***.
   1. Under **FAIL**, select **DONE**.
   2. Under **SUCCESS**, select ***Twosense MFA***.
      * Click **Options**, and in the **Incoming User ID** form:
        * Set **Attribute** to **objectSid**.
        * Check **User ID Authenticated**.
        * Click **Done**.
   3. Under **SUCCESS** for the Twosense and manual MFA IdP adapters, select the appropriate policy contract.
   4. Under **FAIL**, select the action you wish to occur when communication between PingFederate and Twosense fails.
   5. Configure the **Rules** for the **Twosense MFA** adapter according to the table in the section below.
7. Click **Done**.
8. In the **Policies** tab, click **Save**.

#### Twosense MFA Adapter Rules

The Twosense adapter will set the `policy.action` attribute to different values for different outcomes. The following table lists the possible values and their meaning. Use these values to create rules to fit your organization's needs.

| **`policy.action` Value** | **Outcome**                                                                                                          |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `no-agent`                | The Twosense agent was not detected on the client machine.                                                           |
| `twosense-client-error`   | An internal error occurred in the Twosense SDK.                                                                      |
| `challenge`               | The user was not authenticated (i.e., due to a low trust score) and should be presented an additional MFA challenge. |

For example, here's how you can customize your policy with rules based on the outcome:

![](/files/FPlQhIPvnpbL6UPuMMLT)

Then you can use these results to determine the next steps in your policy:

![](/files/fuM3dpyXSAWynUTVOcZY)

## Twosense Session Adapter Configuration

{% hint style="warning" %}
Most customers don't need to set this up. You can stop here unless you require Twosense session information to make policy decisions.
{% endhint %}

If your setup requires information about the authenticating user's current Twosense session, you can set up the Twosense Session Adapter to retrieve this information and use it in your policy.

### Create Twosense Data Store

1. Navigate to **SYSTEM** and select **Data Stores**.
2. Click **Add New Data Store**.
3. In the **Data Store Type** tab, set the following:
   * *Name*: **Twosense API**
   * *Type*: **REST API**
   * Click **Next**.
4. In the **Configure Data Store Instance** tab, perform the following:
   1. Add a new row to "Base URLs and Tags".
      * *Base URL*: `https://webapi.twosense.ai`
      * Click **Update**.
   2. Add the following rows to "Attributes".
      * `startTime` -> `/startTime`
      * `userId` -> `/userId`
      * `device` -> `/device`
      * `ipAddress` -> `/ipAddress`
   3. Set **Authentication Method** to "OAuth 2.0 Bearer Token".
   4. Set **OAuth Token Endpoint** to `https://webapi.twosense.ai/oauth/token`.
   5. Set **Client ID** and **Client Secret** to the values provided by Twosense.

### Create Twosense Session Adapter

1. Navigate to **AUTHENTICATION** and select **IdP Adapters**.
2. Click **Create New Instance**.
3. In the **Type** tab, set the following:
   * *Instance Name*: **Twosense Session Form**
   * *Instance ID*: **TwosenseSessionForm**
   * *Type*: **HTML Form IdP Adapter**
   * Click **Next**.
4. In the **IdP Adapter** tab, under **Password Credential Validator Instance**, click **Add a new row to 'Credential Validators'**:
   * Select **Twosense MFA RADIUS PCV**
   * Click **Update**.
   * Set the following fields:
     * *Challenge Retries*: **1**
     * Click **Show Advanced Fields**.
     * *Login Template*: **html.form.twosense.session.embedded.html**
     * *Allow Username Edits During Chaining*: **true**
     * Click **Next**.
5. In the **Extended Contract** tab, extend the contract with the following fields as needed per your requirements:
   * `sessionStartTime`
   * `sessionUserId`
   * `sessionDevice`
   * `sessionIpAddress`
   * Click **Next**.
6. In the **Adapter Attributes** tab, check the **Pseudonym** checkbox for the **username** attribute, and click **Next**.
7. In the **Adapter Contract Mapping** tab, click **Configure Adapter Contract**.
   1. In the **Attribute Sources & User Lookup** tab, click **Add Attribute Source**.
      1. In the **Data Store** tab, set the following:
         * *ATTRIBUTE SOURCE ID*: **TwosenseAPI**
         * *ATTRIBUTE SOURCE DESCRIPTION*: **Twosense API**
         * *ACTIVE DATA STORE*: **Twosense API**
         * Click **Next**.
      2. In the **Configure Data Source Filters** tab, set the following:
         * *RESOURCE PATH*: `/sessions/${policy.action}`
         * Click **Next**.
   2. In the **Adapter Contract Fulfillment** tab, set the **Source** field to "Other (Twosense API)" for each of the extended contract attributes, then set the **Value** field to the corresponding attribute name.
   3. In the **Issuance Criteria** tab, click **Next**.
   4. In the **Summary** tab, click **Done**.
   5. Click **Next**.
8. Review the **Summary** tab, and click **Save**.

#### Usage in Policies

You can use this adapter anywhere in your policy where you need to retrieve the current user's Twosense session information.

To use the adapter, add it to your policy and ensure the `userSid` is being passed as the user ID in **Options** → **Incoming User ID**.

Create a rule on the adapter which checks that the session attribute of interest (e.g., `sessionUserId`) is not empty (set "Value" to a single space, since Ping does not allow you to set it to an empty string), and make sure "Default to Success" is unchecked.

![](/files/Lo0Up04Lugg2I3q1SfCt)

Using the example above, we end up with two branches from the adapter: "Fail" and "Session".

![](/files/mWu69vAwONGw1XgJbrlX)

The "Fail" branch will be triggered if the user's computer does not have Twosense, or if there is no session for the authenticating user. The "Session" branch will be triggered if the session is found, and you will be able to use the session attributes further in your policy.


# Introduction

These are the docs for the Twosense Windows Authenticator.


# Windows Installation Guide

The Twosense Windows Authenticator can be installed either via the GUI or the command line.

* For GUI installation, refer to the [GUI Installation](#gui-installation) section.
* For command line installation, refer to the [Command Line Installation](#command-line-installation) section.
* If your organization uses an enterprise antivirus solution or enforces strict firewall rules, additional configurations may be required. Please refer to [Anti-Virus Configuration](/troubleshooting/anti-virus-configuration) for detailed instructions.

***

### Requirements

* **Supported Windows Versions (64-bit only)**:
  * Windows 10 (version 1803 or later)
  * Windows 11
* **Twosense Account:** [Get a 30-day trial](https://www.twosense.ai/demo) if you don't have one.
* **Integration Key & Secret Key:** Provided by your Twosense account manager.
* **Administrator Privileges:** Required during installation.
* **Internet Connectivity:** Must be active at all times.
* **.NET Framework:** Version 4.0 or greater must be installed.

***

### GUI Installation

1. Download the Twosense Installer MSI. The link will be provided by your Twosense account manager.
2. Double-click on the MSI file to begin the installation process.
3. Enter your Integration Key, Secret Key, and optionally, a Group ID when prompted. This information is provided by your Twosense account manager.\
   ![](/files/n1eF7yfa73Ya78o3mILI)
4. Reboot after the installation has finished.

***

### Command Line Installation

1. Download Twosense Installer MSI. The link will be provided by your Twosense account manager.
2. Open a Command Prompt or PowerShell (**as Administrator**), and navigate to the file path where the MSI file is located.
3. Enter the following command (replace with the appropriate MSI filename and parameters):\
   \
   `msiexec.exe /i TwosenseAuthenticator-x.y.z.msi /qn+ IKEY="[your key here]" SKEY="[your key here]" GROUPID="[your group id]"`\
   \\

   **Parameters:**

   * **IKEY**: Your integration key. (Required)
   * **SKEY**: Your secret key. (Required)
   * **GROUPID**: The group ID for the machine. (Optional)
   * **IGNORERDP**: Set to *1* to bypass Twosense when logging into the machine via RDP. If set to *0* or left unset, Twosense will operate normally during RDP login. (Optional)
   * **SKIPVALIDATION**: Set to *1* to bypass installation validations. If set to *0* or left unset, the installer will run its normal validation checks, which include verifying that the IKEY and SKEY are properly configured and validated. (Optional)

   **Notes**

   * The values for parameters `IKEY`, `SKEY`, and `GROUPID` are **case-sensitive**.
   * To disable showing the success/failure message post-installation, change the `/qn+` to `/qn`.
   * To enable logging add `/l*v twosense-installer-log.txt` to the end of the command. You can specify a different filename or path as needed.
4. Reboot after the installation has finished.

### Validation

To check that the installation was successful:

* After rebooting the machine, log in as any user.
* Open the Twosense portal at <https://app.twosense.ai/login>.
* You should see the login event on the Events page.


# Group Policy Deployment

## Overview

This guide will help you deploy the Twosense Agent to your Windows computers using Group Policy.

## Steps

### 1. Create GPO for Twosense Installation

#### 1.1 Software Package Settings

Group policy has settings for targeting computers and settings to target users. This guide will focus on targeting computers.

1. Open the **Group Policy Management Console** (GPMC) on your domain controller.
2. Navigate to the **OU where you want to apply the GPO**, right-click and select **"Create a GPO in this domain, and Link it here..."**.
3. Name the GPO `Twosense Installation` and click OK.
4. Right-click the new GPO and select **Edit...**.
5. Navigate to **Computer Configuration > Policies > Software Settings > Software Installation**.
6. Right-click **Software Installation** and select **New > Package**.
7. Browse to the *Twosense MSI file* and click **Open**.

   > ⚠️ The MSI file must be on a network share that all computers in the OU can access.
8. On the Deploy Software dialog, select **Advanced** and click OK.
9. Add the version number to the *Name* field, e.g. `Twosense Authenticator 1.0.0`.
10. In the *Deployment* tab, select **Assigned**.

    ![Deploy Properties Screenshot](/files/M1f2tAW23GuHvWHJESdX)

    > ⚠️ If the *Install this application at logon* option is greyed out, click **Assigned** again. It should be enabled now.
11. Check the box for **Install this application at logon**.
12. Check the box for **Uninstall this application when it falls out of the scope of management**.

    *This will uninstall the software if the computer is moved out of the OU where the GPO is linked.*
13. On the *Modifications* tab, click **Add** and browse to the `*.mst` file that was provided to you.

    ![Modifications Screenshot](/files/65VtkjQ8g2euyrasjjIZ)

    > ⚠️ The MST file must be on a network share that all computers in the OU can access.
14. Click **OK** to close the *Properties* dialog.

#### 1.2 Enable wait for network on startup

In some environments, the installation may fail with error 1274. This is due to the computer not waiting for the network to be available before attempting to install the software. To fix this, you can enable the "Always wait for the network at computer startup and logon" policy.

* In the GPO editor, navigate to *Computer Configuration > Policies > Administrative Templates > System > Logon*.
* Double-click *"Always wait for the network at computer startup and logon"*.
* Select *"Enabled"* and click *OK*.

  ![Always wait for network Screenshot](/files/m5GVaZmlGB0riVjYPWnw)

### 2. Test the GPO Deployment

* In *Active Directory Users and Computers*, move a test computer to the OU where the GPO is linked.
* Log in to the test computer and run *gpupdate /force* from the command prompt.
* Restart the computer and log in again.

> ℹ️ You can verify the installation by checking the *Add/Remove Programs* list in the Control Panel. However, the Twosense services may not be running yet. This is normal and the services will start after the next reboot.

* To verify that the installation was successful. Restart the computer again and log in. The login event should show up in the Twosense portal under *"Event Log"*.

  ![Event Log Screenshot](/files/E7RvR2Kzg9j6JdRvz9cp)


# Proxy support

Starting with version **3.8.0**, the Twosense Endpoint Agent supports routing its internet communication through a proxy server.

This feature is configured using Windows Registry keys at:

```
HKEY_LOCAL_MACHINE\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator
```

The following registry values control proxy configuration:

* **ProxyUrl** (REG\_SZ): The hostname or IP address of your proxy server
* **ProxyPort** (REG\_SZ): The port number for the proxy connection

You can configure these registry keys using PowerShell (shown below), manual registry editing, or Group Policy Object (GPO) for enterprise deployments.

## Configure Proxy

### Prerequisites

* Administrative privileges
* PowerShell access

### Steps

1. Open PowerShell **as Administrator**.
2. Run the following commands:

   ```powershell
   New-Item -Path "HKLM:\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator" -ErrorAction SilentlyContinue | Out-Null
   Set-ItemProperty -Path "HKLM:\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator" -Name "ProxyUrl" -Value "proxy.example.com"
   Set-ItemProperty -Path "HKLM:\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator" -Name "ProxyPort" -Value "8080"
   ```

   **Parameters:**

   * **ProxyUrl**: The hostname or IP address of your proxy server (e.g., `proxy.example.com`, or `https://proxy.example.com`)
   * **ProxyPort**: The port number for the proxy connection (e.g., `8080`)

## Disable Proxy

### Steps

1. Open PowerShell **as Administrator**.
2. Run the following commands:

   ```powershell
   Remove-ItemProperty -Path "HKLM:\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator" -Name "ProxyUrl" -ErrorAction SilentlyContinue
   Remove-ItemProperty -Path "HKLM:\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator" -Name "ProxyPort" -ErrorAction SilentlyContinue
   ```


# Upgrade Guide

This guide provides instructions for upgrading to the latest version of the Twosense Endpoint Agent from different starting versions.

***

## Upgrading from v3.x

1. **Download the Latest Installer**\
   Request the latest Twosense Installer MSI by contacting <support@twosense.ai>.
2. **Install the Latest Version**\
   Follow the detailed steps in the [Windows Installation Guide](/windows-authenticator/guides/windows-installation-guide).
3. **Reboot**\
   Restart the machine once the installation completes to apply the updates.

***

## Upgrading from v2.x or Earlier

If you are upgrading from v2.x or earlier, there are two possible configurations. Follow the appropriate steps based on your setup.

### Scenario 1: Single Installer Package

If you installed the Twosense services using a single installer package, follow these steps:

1. **Uninstall the Single Installer**\
   Open **Add/Remove Programs** and locate **Twosense Continuous MFA**. Uninstall it. Alternatively, use your software management system or Group Policy (GPO) to uninstall the package.
2. **Reboot Your System**\
   Restart your machine after the uninstallation.
3. **Install the Latest Version**\
   Follow the steps in the [Windows Installation Guide](/windows-authenticator/guides/windows-installation-guide).
4. **Reboot Again**\
   Restart your machine after the new installation is complete.

### Scenario 2: Multiple Installers

If you installed the Twosense services using multiple installer packages, follow these steps:

1. **Uninstall Services in Order**\
   Uninstall the following packages in the specified order:

   1. **Twosense Authenticator**
   2. **Twosense Manager Approval Client** (if installed)
   3. **Twosense Continuous MFA** (if installed)

   You can use **Add/Remove Programs**, Group Policy (GPO), or your software management system to perform the uninstallation.
2. **Reboot Your System**\
   Restart your machine after all services are uninstalled.
3. **Install the Latest Version**\
   Follow the steps in the [Windows Installation Guide](/windows-authenticator/guides/windows-installation-guide).
4. **Reboot Again**\
   Restart your machine after the new installation is complete.

***

### Notes

* Ensure you have administrative privileges during installation.
* If you encounter issues, contact Twosense Support at <support@twosense.ai>.


# Emergency Disable Mode

**Emergency Disable Mode** is a controlled, admin-only method for temporarily disabling Twosense behavioral authentication in rare and critical situations — such as troubleshooting, system recovery, or providing emergency access.

When enabled, Twosense behavioral authentication is fully disabled. Windows will fall back to its default authentication method or any other configured MFA (e.g., Duo).

***

## ℹ️ Version Requirement

* **Introduced in endpoint agent v3.8.0**
* This feature will **not work** on earlier versions.

***

## ⚠️ Important Security Notice

* While Emergency Disable Mode is active, **Twosense behavioral authentication is not performed at Windows login**.
* Authentication will rely only on your default Windows or MFA configuration.
* This significantly reduces your security posture.
* **Re-enable Twosense as soon as possible after resolving the issue.**

***

## When to Use

Use Emergency Disable Mode to:

* Troubleshoot login or authentication issues
* Perform network or system recovery
* Regain access when Twosense service problems prevent login

## When *NOT* to Use

Do **not** use Emergency Disable Mode to:

* Bypass security policies
* Perform routine administrative access
* Make long-term configuration changes

***

## Choosing the Right Method

| Scenario                                 | Recommended Method                                          | Remote Access? |
| ---------------------------------------- | ----------------------------------------------------------- | -------------- |
| You have local admin access              | [Admin Access](#id-1.-admin-access)                         | No             |
| You have remote PowerShell access        | [Remote PowerShell](#id-2.-remote-powershell)               | Yes            |
| Remote access unavailable; locked out    | [Safe Mode](#id-3.-safe-mode)                               | No             |
| Need to disable across multiple machines | [Group Policy Object (GPO)](#id-4.-group-policy-object-gpo) | Yes            |

***

## 1. Admin Access

Disable Twosense locally via the Windows Registry.

### Prerequisites

* Local administrator rights

### Steps

1. Open Registry Editor.
2. Navigate to:

   ```
   HKEY_LOCAL_MACHINE\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator
   ```
3. Create a DWORD named `DisableAtLogon` if it doesn't exist, and set its value to 1.
4. Restart the machine or log off/on.

### Re-enable Twosense

Set `DisableAtLogon` to `0`, then restart or log back in.

***

## 2. Remote PowerShell

Disable Twosense on a remote machine by updating the registry.

### Prerequisites

* Administrative privileges
* PowerShell Remoting enabled
* Network connectivity to target

### Steps

1. In an elevated PowerShell session, run:

   ```powershell
   Invoke-Command -ComputerName TARGET_COMPUTER_NAME -ScriptBlock {
       Set-ItemProperty -Path "HKLM:\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator" -Name "DisableAtLogon" -Value 1 -Type DWord -Force
   }
   ```
2. Restart the target machine or log off/on.

### Re-enable Twosense

Run the same command but set the value to `0`.

***

## 3. Safe Mode

Use when normal or remote access is unavailable.

### Prerequisites

* Physical access
* Administrative credentials

### Steps

1. Boot into Windows Safe Mode.
2. Open Registry Editor.
3. Navigate to:

   ```
   HKEY_LOCAL_MACHINE\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator
   ```
4. Create a DWORD named `DisableAtLogon` if it doesn't exist, and set its value to 1.
5. Restart normally.

### Re-enable Twosense

Log in as admin, set `DisableAtLogon` to `0`, restart.

***

## 4. Group Policy Object (GPO)

Disable Twosense across multiple domain-joined machines.

### Prerequisites

* Access to Group Policy Management Console (GPMC)
* Domain-joined machines receiving GPO updates

### Steps

1. Open GPMC and create or edit a GPO linked to the target OU.
2. Go to:

   ```
   Computer Configuration > Preferences > Windows Settings > Registry
   ```
3. Create a new Registry Item:
   * **Action:** Update
   * **Hive:** HKEY\_LOCAL\_MACHINE
   * **Key Path:** SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator
   * **Value name:** DisableAtLogon
   * **Value type:** REG\_DWORD
   * **Value data:** 1
4. Restart target machines.

### Re-enable Twosense

Update the same GPO to set `DisableAtLogon` to `0` and apply again.


# Introduction

These are the docs for using Twosense with the H2FA (Human 2 Factor Authentication) feature.


# Microsoft Teams Deployment

This guide outlines the steps required to set up the Twosense bot within your Microsoft Teams environment. The process includes creating a custom app, uploading the bot, configuring permissions, and installing the bot into a Team.

{% hint style="warning" %}
These changes can take anywhere between a few minutes and up to 24 hours to take effect. This is a limitation of the Microsoft Teams product.
{% endhint %}

## Allow custom apps

1. Navigate to [Microsoft Teams Manage Apps](https://admin.teams.microsoft.com/policies/manage-apps)
2. Click on **Teams apps**, then select **Setup policies**.
3. You will see a list of policies applied to your users. For detailed precedence rules, refer to [Microsoft's policy precedence documentation](https://learn.microsoft.com/en-us/microsoftteams/assign-policies-users-and-groups#precedence-rules).
4. Ensure that the **Allow custom apps** option is enabled for users who will use the Twosense MFA bot. For example, if you only have the **Global policy** that applies to all users, it should look like this:

<figure><img src="/files/BnJtpM9wMLathI3b7kFp" alt=""><figcaption></figcaption></figure>

## Upload Twosense Bot to Teams

1. Navigate to [Microsoft Teams Manage Apps](https://admin.teams.microsoft.com/policies/manage-apps)
2. Click on **Teams apps**, then select **Manage Apps**
3. Click **Actions** in the top-right corner and choose **Upload new app**.
4. Click **Upload** and select the file `TwosenseMsTeamsBot-x.y.z.zip` provided by your Twosense Account Manager.

## Edit app permissions

1. Navigate to [Microsoft Teams Manage Apps](https://admin.teams.microsoft.com/policies/manage-apps)
2. Click on **Teams apps**, then select **Manage Apps**.
3. Search for **Twosense MFA** and click on the app name.
4. Go to **Users and Groups**. If you can't find this section, refer to [Microsoft’s app-centric management guide](https://learn.microsoft.com/en-us/microsoftteams/app-centric-management).
5. Click **Edit availability** and choose one of the following options:
   * **Everyone**: All users in your organization can use the app.
   * **Specific users or groups**: Ensure all users who will approve requests are listed.

<figure><img src="/files/lBE4ahdWqcbdc2eu299m" alt=""><figcaption></figcaption></figure>

## Add Twosense Bot to a Team

1. Navigate to [Microsoft Teams Manage Apps](https://admin.teams.microsoft.com/policies/manage-apps)
2. Click on **Teams apps**, then select **Manage Apps**.
3. Search for **Twosense MFA** and click on the checkbox to the left of the app name.
4. Click on **Add to Team**.
5. Search for the team where you want to install the bot and click **Apply**

<figure><img src="/files/S08BGWGWclOl6ElAixed" alt=""><figcaption></figcaption></figure>

If you encounter any issues, please contact <support@twosense.ai>.


# Subscribing MS Teams Channel

## Subscribe a channel

To receive sign-in request notifications from Twosense MFA in your Microsoft Teams channel, follow these steps:

1. Navigate to the Team where you added the bot.
2. Go to the channel you want to receive sign-in request notifications.
3. Type `@Twosense MFA subscribe <suscription_key>` and press Enter. Make sure to replace `<subscription_key>` with the subscription key provided by your Twosense account manager.

<figure><img src="/files/3aX2UARcYHUCdvhPafay" alt=""><figcaption></figcaption></figure>


# Configuring Group-Based Notifications

This guide will help you configure the Groups feature to route login requests from specific machines to designated MS Teams channels. This is particularly useful for organizations with multiple Business Units or Lines of Business (LOBs) that require requests to be sent to different supervisory teams.

## Step 1: Provisioning Groups

### 1. Contact Support:

* Begin by contacting our support team to provision the necessary groups for your organization.
* You will receive a list of **Group IDs** and their corresponding **Subscription Keys** after the groups are provisioned.

### 2. Receive Group Details:

* The support team will provide you with:
  * **Group IDs**: Unique identifiers for each group.
  * **Subscription Keys**: Codes used to subscribe to specific MS Teams channels.

## Step 2: Subscribing MS Teams Channels

1. **Log into MS Teams**: Open the MS Teams application and navigate to the channel where you want to receive the 2FA login requests.
2. **Subscribe MS Teams Channel**: Use the provided Subscription Key to [subscribe the channel](/h2fa/guides/subscribing-ms-teams-channel) to requests for the corresponding group.

## Step 3: Assigning Machines to Groups

### During Installation

1. **Install the Twosense Endpoint Agent**:
   * During the installation of the endpoint agent on a machine, you will see a field labeled “**Group ID**” in the GUI installer.
2. **Enter the Correct Group ID**:
   * Enter the **Group ID** corresponding to the appropriate group for that machine.
   * Ensure that the correct Group ID is used to avoid misrouting requests.

### Post-Installation (Using Registry Key or Group Policy)

1. **Modify the Registry Key**:
   * If you need to assign or change the Group ID after installation, modify the registry key on the machine.
   * Navigate to the registry path `HKEY_LOCAL_MACHINE\SOFTWARE\TWOSENSE.AI\TwosenseAuthenticator` and update the `GroupId` key.
2. **Using Group Policy**:
   * You can also deploy Group IDs via Group Policy for multiple machines.
   * Update the **Computer Configuration** → **Preferences** → **Windows Settings** → **Registry** Group Policy to set the Group ID for each machine.


