> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aviatrix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting Up Okta SAML with Profile Attribute

> This guide demonstrates the use of the Profile attribute in Okta so each SAML user can be assigned a different VPN profile.

This guide demonstrates the use of the **Profile** attribute in **Okta** so each
SAML user can be assigned a different VPN profile.

## How a VPN Profile Works

The VPN profiles defined at **CoPilot > Cloud Fabric > UserVPN > Profiles**
contain an egress control policy. They are attached to the VPN users defined at
**CoPilot > Cloud Fabric > UserVPN > Users** for controlling their VPN egress
traffic.

If a user does not have an assigned profile, they are considered to have a
blanket **allow-all** policy applied, which means their egress traffic is
unrestricted.

For SAML VPN, the SAML user definition at the IdP has a **Profile** attribute
for specifying a VPN profile, overriding the corresponding user's VPN profile
assigned in CoPilot. If unspecified, the corresponding VPN profile assigned in
CoPilot will be used.

## Setting up the Okta Profile Attribute

1. [Define a new attribute](#defining-a-new-attribute) in the Okta User template
   for storing the VPN profile name.
2. [Define an attribute mapping](#defining-an-attribute-mapping) for the new
   attribute using the name **Profile** so that the SAML application knows how
   to compose the **Profile** information in the SAML response.
3. [Assign VPN profile](#assigning-the-vpn-profile-to-each-saml-user) to each
   SAML user.
4. [Validate](#validation) the setup.

## Defining a New Attribute

At Okta, define a new attribute in the **User** definition template using
**Okta/Directory/Profile Editor**. In this example, the new attribute is named
**accessprofile** and it can store a string of up to 20 characters.

1. Open Profile Editor at **Okta/Directory/Profile Editor**.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/open-profile-editor.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=b70d1c37dd444ea6de54708d999c1d97" alt="open_profile_editor" width="1350" height="615" data-path="images/guides/uservpn/open-profile-editor.png" />

2. Click **Okta** on the left navigation bar to find the **User** definition
   template and click **Profile** to open.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/open-user-template.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=418e65472cb8d7883ff0240513d1f95d" alt="open_user_template" width="1303" height="772" data-path="images/guides/uservpn/open-user-template.png" />

3. Click **Add Attribute** to add a new attribute in the user template.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/profile-editor-add.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=f33f51888da8156059adfffdb3647238" alt="profile_editor_add" width="1295" height="822" data-path="images/guides/uservpn/profile-editor-add.png" />

4. Define a string attribute with a name; in this example, we use
   **accessprofile**.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/add-profile-attribute-user-template.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=7fc5f0888968124769d54ae6657be6f5" alt="add_profile_attribute_to_user_template" width="848" height="628" data-path="images/guides/uservpn/add-profile-attribute-user-template.png" />

## Defining an Attribute Mapping

In the SAML application
(`Okta/Applications/<your-vpn-saml-app>/General/SAML Settings/Edit`), define a
mapping for the new attribute (e.g., **accessprofile**) using the name
**Profile**. Note that the name **Profile** is required to be an exact match and
the new attribute name is pre-qualified with the keyword **user** for
referencing a property in the user template.

<img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/add-profile-attribute-app.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=f49fc11575cd30c009f6e286e9067779" alt="add_profile_attribute_to_app" width="904" height="458" data-path="images/guides/uservpn/add-profile-attribute-app.png" />

## Assigning the VPN Profile to Each SAML User

For each SAML application user, edit the user record in the Okta directory for
assigning the VPN profile (`Okta/Directory/People/<your-user>/Profile/Edit`). In
this example, the VPN profile defined at the Controller is named
**access-profile**. Currently, only one profile is allowed per SAML user.

<img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/add-profile-attribute-user.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=2c40c861d24a094dbb968ed7a1e3b863" alt="add_profile_attribute_to_user" width="891" height="475" data-path="images/guides/uservpn/add-profile-attribute-user.png" />

## Validation

The following example illustrates the use of the SAML user's **Profile**
attribute explained in previous sections:

* It uses an Aviatrix VPN Gateway that has **certificate sharing** enabled. That
  is, only one VPN user is created at the Aviatrix VPN Gateway. The
  corresponding **ovpn** file will be shared by all SAML VPN users defined in
  Okta.
* Two VPN profiles are created: The **default-profile** contains a base deny-all
  policy and is attached to the VPN user, stopping all VPN egress traffic by
  default. The **access-profile** contains the desired egress-traffic-allow
  policies. As a result, only the SAML users who have his/her **Profile**
  attribute set to **access-profile** will have the right VPN access while
  others will be restricted by the **default-profile**.
* For testing purposes, create two SAML users in Okta, respectively, with and
  without setting the **Profile** attribute to **access-profile**.

Here are the steps for setting up the example:

1. Follow the guide

   <a href={"/docs/enterprise/" + "10.1" + "/guides/uservpn/user-vpn-saml-authentication-okta"}>Aviatrix SAML Authentication on Okta IdP</a>

   to configure the Controller to authenticate against the Okta IDP. The
   Aviatrix SAML Endpoint in this example is named vpn-5-1-okta (**CoPilot >
   Cloud Fabric > UserVPN > Settings**):

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/vpn-5-1-okta.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=baef16046f14041f7f332e0440b6f060" alt="vpn-5-1-okta" width="3028" height="930" data-path="images/guides/uservpn/vpn-5-1-okta.png" />

2. Ensure that your VPN gateway has Client Certificate Sharing and Split Tunnel
   enabled.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/cert-sharing.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=56cf81c8f34da25572a63f88744e503d" alt="cert-sharing" width="1538" height="412" data-path="images/guides/uservpn/cert-sharing.png" />

3. Create a **default-profile** with base deny-all policy
   (`Controller/OpenVPN/Profiles/Add new`). This default-profile will be
   attached to the VPN user, i.e., no egress traffic is allowed by default.

4. Create a second profile the **access-profile** with base deny-all policy and
   subsequently edit it to add the allowed egress traffic
   (`Controller/OpenVPN/Profiles/<access-profile>/Edit`). This VPN profile will
   be assigned to the SAML User at the Okta IDP. For the purpose of this test,
   it can contain any dummy policy.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/access-profile.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=6a44d8103fee903d1adeb4fd29f8870e" alt="access-profile" width="2474" height="638" data-path="images/guides/uservpn/access-profile.png" />

5. Create one VPN user with the **default-profile**.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/vpn-user.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=4c56fd29963703af0c85b3572efde657" alt="500" width="902" height="836" data-path="images/guides/uservpn/vpn-user.png" />

6. Download the **ovpn** file of the VPN user just created and load it into the
   Aviatrix VPN client.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/download-ovpn.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=1a9c4d4b195f08414265cacd1ab8ce53" alt="download-cert" width="1067" height="471" data-path="images/guides/uservpn/download-ovpn.png" />

7. Create two users in Okta (`Okta/Directory/People/Add Person`). For ease of
   identification, user1 is given an email address at gmail.com and user2 at
   yahoo.com.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/add-person.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=0c884f4491621e1345915413b23e57b6" alt="add-person" width="743" height="680" data-path="images/guides/uservpn/add-person.png" />

8. Assign the SAML VPN application to the two users in Okta
   (`Okta/Directory/People/<your-saml-user>/Applications/Assign Applications`).
   In this example, **vpn-5-1** is our VPN SAML application.

   <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/assign-app.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=9224c52fbdc19efed3795086a11a9660" alt="assign-app" width="772" height="294" data-path="images/guides/uservpn/assign-app.png" />

9. Follow Steps 1 and 2 in
   [Setup Okta Profile attribute](#setting-up-the-okta-profile-attribute) to
   define the **Profile** attribute in Okta.

10. Follow [Assign VPN profile](#assigning-the-vpn-profile-to-each-saml-user) to
    set user1's **Profile** attribute to **access-profile**.

11. From the Aviatrix VPN client, make a VPN connection using user1 Okta
    credential and observe the result at **Controller/Dashboard**. Repeat the
    same for user2. The following screenshots show the results.
    * **User1 (gmail.com)** with **Profile** attribute set to
      **access-profile**:

      <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/browser-user-with-profile.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=7d42f64d699346ec92893da27dfe2616" alt="browser_user_with_profile" width="1255" height="530" data-path="images/guides/uservpn/browser-user-with-profile.png" />

    * **User2 (yahoo.com)** without setting the **Profile** attribute:

      <img src="https://mintcdn.com/aviatrix-14b37c43/MwMAaVUDwCmP6YfF/images/guides/uservpn/browser-user-without-profile.png?fit=max&auto=format&n=MwMAaVUDwCmP6YfF&q=85&s=ba16217076e0a70052bdc62d1ef46966" alt="browser_user_without_profile" width="1197" height="507" data-path="images/guides/uservpn/browser-user-without-profile.png" />
