> 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/access/third-party-access.md).

# Restrict a third party to specific assets

Confine a third party to a set of assets, inside a time window, with every connection approved by an auditor: three settings that only work together.

## What this is and when to use it

A contractor, a vendor, or a service provider often needs administrative access to a handful of assets, never to the whole environment, and only at agreed hours. This page builds that access for a user who already exists, for example one who signs in with a directory account over LDAP.

Three settings are involved, and each closes a different gap:

| Setting                     | What it limits                                                                | Where                        |
| --------------------------- | ----------------------------------------------------------------------------- | ---------------------------- |
| A role without just-in-time | What the user can **see**: it removes the request menu that lists every asset | **Users › Profiles**         |
| An authorization            | **Which** assets and accounts the user can reach                              | **Policies › Authorization** |
| An asset connect rule       | **When** a connection is possible, and **whose approval** it needs            | **Policies › Asset connect** |

Do them in this order.

{% hint style="warning" %}
**An authorization alone is not enough.** With access limited to a few assets, the user can still browse every asset in the environment through the just-in-time request menu, unless step 1 removes it from their role.
{% endhint %}

## Before you start

* The **SYSADMIN** profile.
* The third-party user already registered, and the assets already in the inventory.
* One or more approvers, typically auditors, who are not the third party. Nobody can approve their own request.
* Email or SMS notifications configured under **System settings › Notifications**, so approvers learn that a request is waiting.

## Steps

### Step 1: remove just-in-time from the user's role

1. Open **Users › Profiles**.
2. Find the role the third-party user currently holds and **Duplicate** it. Working on a copy leaves the original role, and everyone else who holds it, untouched.
3. Click the name of the new role to open it.
4. On the **Basic** tab, scroll to **Permission** and search for `ticket`.
5. Untick **Ticket flow** and **Ticket**.
6. Click **Update**.
7. Give the user the new role in place of the old one: on the role's **Authorized users** tab click **Add**, then remove the original role from the user. Permissions from several roles add up, so a user who keeps the original role keeps just-in-time.

![The Permission tree of a duplicated role, filtered by "ticket"](https://1085357737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7xzJyi9JVzRwnV6JzUho%2Fuploads%2Fgit-blob-e74389ed54d9e5d09fdbb8aa4fadda020e8a904b%2Fthird-party-access-role-ticket-permissions.png?alt=media)

The role's **Permission** tree filtered by `ticket`, with the ticket permissions unticked.

Just-in-time requests are no longer available to anyone who holds the new role, so the request menu stops exposing assets outside the authorization.

### Step 2: grant only the intended assets

1. Open **Policies › Authorization** and click **Create**.
2. Under **Basic**, give the rule a **Name** that says who gets what, for example `Third party - Contoso - database servers`.
3. Under **User**, select the third-party user.
4. Under **Asset**, select only the assets this user may reach.
5. Under **Account**, choose **All existing accounts**. Choosing a single account does not, by itself, confine the user to it: if other authorizations grant other accounts on the same asset, those remain available, because overlapping rules add up.
6. Under **Protocol**, keep all protocols, or keep only those the work needs.
7. Under **Action**, review the permitted actions: connect, upload, download, delete, copy, paste, share, and sudo password. Untick what the work does not need; for a third party, file transfer and session sharing are the usual candidates.
8. Under **Other settings**, keep **Active** ticked. Set **Expiration date** to the end of the contract, so the grant does not outlive it.
9. Click **Confirm**.

{% hint style="info" %}
With every action ticked, this authorization lets the user connect at any hour and without approval. The time window and the approval come from step 3.
{% endhint %}

### Step 3: hold each connection for approval, inside a time window

This step creates an asset connect rule that holds each connection made inside the allowed hours until an approver releases it.

1. Open **Policies › Asset connect** and click **Create**.
2. Under **Basic**, enter a **Name** that identifies the user, for example `Third party - Contoso - review`, and a **Priority**, for example `10`.
3. Under **Users**, select the third-party user.
4. Under **Asset**, keep **All**. The rule then also covers assets registered later, with no need to edit it.
5. Under **Accounts**, keep **All existing accounts**.
6. Under **Rules**, mark on the weekly time grid the hours in which access is allowed.
7. Under **Action**, choose **Evaluate**, the review action. In the **Custodians** field that appears below it, select the approvers.
8. Click **Confirm**.

{% hint style="warning" %}
**Outside the allowed hours, this rule does not apply.** A rule matches only while its time grid covers the current moment, so outside the window no rule matches and the connection goes through with no approval. To refuse it, create a second asset connect rule for the same user, with **All** under **Asset**, **All existing accounts** under **Accounts**, the time grid left empty under **Rules** (an empty grid applies at every hour of every day), **Deny** under **Action**, and a **Priority** higher than this rule's, for example `20`. Rules are evaluated from the lowest priority number up: inside the window this rule holds the connection, and outside it the deny rule refuses it.
{% endhint %}

## What you should see

The duplicated role appears under **Users › Profiles**, the authorization under **Policies › Authorization** with the **Valid** column showing it in force, and the rule under **Policies › Asset connect**, active, together with the deny rule from the note in step 3 if you created it. The result for the third-party user:

| Aspect     | Result                                                                             |
| ---------- | ---------------------------------------------------------------------------------- |
| Visibility | No just-in-time request menu, so no list of assets outside the scope (step 1)      |
| Access     | Only the assets in the authorization (step 2)                                      |
| Control    | Connections inside the allowed hours held until an approver releases them (step 3) |

## How to verify it worked

You need two accounts: the third-party user and one of the approvers.

1. Sign in as the third-party user. The just-in-time request menu must not be there.
2. Open the asset list. Only the assets from the authorization must appear.
3. Inside the allowed hours, open a session to one of them. The connection must be **held** with a message that approval is required, not opened and not refused.
4. As the approver, find the pending request and approve it. The third party's connection must then open.
5. Outside the allowed hours, try again. With the deny rule from the note in step 3, the connection must be refused; without it, it opens with no approval.
6. Open **Audit › Sessions › Requests** and confirm the request and its decision are recorded.

Step 5 shows what happens outside the window. Without the deny rule, a connection there opens with no approval, and the configuration still looks right from every screen.

## Common errors

| Symptom                                                          | Cause                                                                                        | Fix                                                                          |
| ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| The user still sees every asset in the request menu              | The user still holds the original role, or another role with the ticket permissions          | Remove every other role from the user, so only the duplicated role remains   |
| Outside the allowed hours, the connection opens without approval | No rule covers those hours: the review rule applies only inside its time grid                | Create the deny rule described in the note in step 3                         |
| Inside the allowed hours, the connection is refused              | The deny rule from the note in step 3 has a lower priority number than the review rule       | Give the review rule the lower number                                        |
| Connections open without approval at any hour                    | The review rule has no approver, and a rule set to **Evaluate** without approvers is skipped | Select at least one approver                                                 |
| The approver is never notified                                   | No email or SMS transport                                                                    | Configure notifications under **System settings › Notifications**            |
| The user reaches an asset that is not in the authorization       | Another authorization covers it, possibly through a user group                               | When authorizations overlap, the least restrictive wins. Find the other rule |
| The user sees no asset at all                                    | The authorization is inactive or outside its validity period                                 | Check the **Valid** column, then **Start date** and **Expiration date**      |

## Field reference

| Where                      | Field                    | Value for a third party                                       |
| -------------------------- | ------------------------ | ------------------------------------------------------------- |
| Duplicated role            | Ticket flow, Ticket      | Unticked                                                      |
| Authorization              | User                     | The third-party user                                          |
| Authorization              | Asset                    | Only the assets in scope                                      |
| Authorization              | Account                  | All existing accounts                                         |
| Authorization              | Protocol                 | All, or only those the work needs                             |
| Authorization              | Action                   | Only the actions the work needs                               |
| Authorization              | Active / Expiration date | Ticked / end of the contract                                  |
| Review rule                | Priority                 | For example `10`; lower than the deny rule's, if there is one |
| Review rule                | Users / Asset / Accounts | The third-party user / All / All existing accounts            |
| Review rule                | Rules                    | The allowed hours on the time grid                            |
| Review rule                | Action                   | **Evaluate**, with the approvers selected                     |
| Deny rule (note in step 3) | Priority                 | Higher number than the review rule, for example `20`          |
| Deny rule (note in step 3) | Users / Asset / Accounts | The same user / All / All existing accounts                   |
| Deny rule (note in step 3) | Rules                    | Empty time grid                                               |
| Deny rule (note in step 3) | Action                   | **Deny**                                                      |

## Related pages

* [Authorizations](https://wiki.datadike.com/pam/administration/access/authorizations.md): what the authorization in step 2 can grant
* [Approval workflows](https://wiki.datadike.com/pam/administration/access/approvals.md): asset connect rules and the review action
* [Just-in-time access](https://wiki.datadike.com/pam/administration/access/just-in-time.md): the request menu that step 1 removes
* [Roles and permissions](https://wiki.datadike.com/pam/administration/identities/roles.md): duplicating and assigning roles
* [Session recording](https://wiki.datadike.com/pam/administration/sessions/recording.md): what is kept of each session
