# Single Sign-On with OKTA

This article explains configuring Single Sign-On (SSO) in CodeScan with Okta as your SAML 2.0 Identity Provider. This enables users to restrict login IPs via SSO.

To allow users to log in via SAML SSO, CodeScan must be able to trust and rely on Okta to authenticate users wanting to log in. To establish this trust relationship, you must configure Okta and CodeScan so both parties can exchange authentication information.

When SSO is enabled, users and groups logging into CodeScan are redirected to the Okta login page. After successful authentication, they are redirected to the AutoRABIT Dashboard.

**Who can use this feature**

1. Only Organization Admins can set up SAML SSO.
2. You will need an existing Okta account to set up SAML SSO with Okta.

### Step 1: Enabling Single Sign-On in CodeScan <a href="#step-1-enabling-single-signon-in-codescan" id="step-1-enabling-single-signon-in-codescan"></a>

Before configuring SSO in OKTA, you must enable SSO in CodeScan.

1. In **CodeScan**, click on the **`Profile`** icon on the right corner of the screen and select your organization (under **`My Organizations`**).\
   ![](https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FlNJKKRZJkynjP7opbdOQ%2Fimage.png?alt=media\&token=e8adae02-5f8c-4ea4-9dd0-365ee16983ae)
2. Go to **`Administration > SAML Connections`**.\
   ![](https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FOV5E0v0ft9X42PfIXgBg%2Fimage.png?alt=media\&token=be03e1f3-55f6-4a54-876d-3c2c68ed3683)
3. Click on **`Create Connection`**.<br>

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FIu1W8mHgT1zjETiemzrr%2Fimage.png?alt=media&#x26;token=638639f0-d25a-4ed7-b8a3-eeb417ef998d" alt=""><figcaption></figcaption></figure>
4. In the **`Connection name`** field, enter the identity provider name as you want to appear (use only Latin characters without spaces and any special characters).\
   **Example-** `OKTA-SAML`
5. Enter a valid domain name of the organization in the **`Corporate domain`** field that can be authenticated in the Identity Provider. ***This property cannot be updated after SAML Connection creation.***\
   **Example**- *In case of `abc@autorabit.com`, the **corporate domain** will be `autorabit.com`*.
6. Keep the **`Enforce SSO`** checkbox unchecked for now. You can enable *Enforce SSO* later when your domain has been confirmed. Once enabled, only SSO authentication will be allowed for email addresses of your corporate domain.

   Point to Note:

   * Enforcing SSO affects both login and signup. Existing *Auth0* users won't be able to login.
   * Signup with email domain same as corporate domain won't be allowed.
   * If the **`Enforce SSO`** is enabled prematurely, it will prevent all **users in their organisation** from accessing CodeScan. Consider enforcing SSO only after admins have logged in to CodeScan using SSO.
7. Keep the **`SAML Connection status`** checkbox as **`Enabled`** and click on **`Create`** button.<br>

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F2vJgL9fnz00H0tO4OYGu%2Fimage.png?alt=media&#x26;token=27073120-609a-4131-80fd-d1e08ec11124" alt="" width="563"><figcaption></figcaption></figure>
8. You will be able to see the **`Metadata URL`** generated for your SSO configuration. Keep the current page open while you continue to add the CodeScan app to OKTA.<br>

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F4kDNEHvjnexLyuTOv8mh%2Fimage.png?alt=media&#x26;token=a7782286-6d38-4b2c-8fa3-a17435e32a0c" alt=""><figcaption></figcaption></figure>

### Step 2: Adding CodeScan as an App in OKTA <a href="#step-2-adding-codescan-as-an-app-in-okta" id="step-2-adding-codescan-as-an-app-in-okta"></a>

Set up the CodeScan application to provide necessary configuration information for CodeScan.

1. Sign in to Okta. You must have the Applications **`Admin`** permission.
2. If you don’t have an Okta organization, you can create a free Okta Developer Edition organization here: <https://developer.okta.com/signup/>
3. Navigate to the **`Admin`** dashboard.
4. From the main menu, go to **`Applications > Applications`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FSJiDBmVdJJmcosFqE3Hq%2Fimage.png?alt=media&#x26;token=829033b8-3937-482b-9ff8-d236b59dc714" alt="" width="252"><figcaption></figcaption></figure>

5. Click on **`Create App Integration`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F1VERoeMJQyN7RlyF6Cgn%2Fimage.png?alt=media&#x26;token=39de28cc-23a6-4246-b881-f4652a35780a" alt="" width="471"><figcaption></figcaption></figure>

6. In the next auto-populated dialog box, select the second option, i.e., **`SAML 2.0`**, and click on **`Next`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F4kkiHTHhWRsAChouFDoN%2Fimage.png?alt=media&#x26;token=d947a62a-3bf4-4715-8177-2490925ce611" alt="" width="563"><figcaption></figcaption></figure>

7. In the **`General Settings`**, enter **`CodeScan`** in the App name field, upload the **`CodeScan logo`** and click on the **`Next`** button.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FTYxvVayap9xwErS9karq%2Fimage.png?alt=media&#x26;token=6357d313-e7e2-43ad-90d8-5c1feb69e84f" alt="" width="563"><figcaption></figcaption></figure>

8. In the **`Configure SAML`** tab, do the following:

   * **`Single sign on URL`**: Enter the same **`URL`** in the below format: *`{instanceurl}/_codescan/login/saml2/sso/{connection_id}`*\
     **For example:** If your *instance URL* is `https://app.codescan.io` and the *connection\_id* is `OKTA-SAML`, your SSO URL would be *`https://app.codescan.io/_codescan/login/saml2/sso/OKTA-SAML`*
   * **`Audience URI (SP Entity ID)`**: Enter your *connection\_id* in this field. **Example:** `OKTA-SAML`

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FDWXmJWSW9GPX9T35Aws5%2Fimage.png?alt=media&#x26;token=5fe3445d-b807-4bad-8df7-f20cdb5ed1bc" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
**Where can I find my Connection ID?**

Your connection id will be available in the **Metadata URL** generated inside CodeScan.

**For example:** *Metadata URL*- <https://app.codescan.io/\\_codescan/saml2/metadata/OKTA-SAML\\>
\&#xNAN;*Connection Id*: OKTA-SAML
{% endhint %}

9. On the same screen, in the **`Attribute Statements`** panel, add the following attributes (mandatory) and map to corresponding OKTA properties:

| Name            | Name format   | Value            |
| --------------- | ------------- | ---------------- |
| `saml_email`    | `Unspecified` | `user.email`     |
| `saml_username` | `Unspecified` | `user.login`     |
| `saml_name`     | `Unspecified` | `user.firstName` |

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FIyge7QftxaBgiDN0TV1L%2Fimage.png?alt=media&#x26;token=b5c4606f-e878-4e7b-ba94-40bd5e8bbb57" alt="" width="563"><figcaption></figcaption></figure>

10. Click **`Next`** to continue.
11. Under the **`Feedback`** section, select the option: **`I'm an Okta customer adding an internal app`** and click the checkbox next to the text **`"This is an internal application that we created"`**, and click on the **`Finish`** button.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FeWufXbdzDXhdm6ckSqAo%2Fimage.png?alt=media&#x26;token=ba6087e3-844c-427f-9130-43f46650facb" alt="" width="563"><figcaption></figcaption></figure>

12. Navigate your mouse to the **`Assignment`** tab, and click **`Assign > Assign to People`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FRMn7mq3T3AJGyUcDM8Sb%2Fimage.png?alt=media&#x26;token=5f15efa0-7b42-4508-b316-064abfcb2fbd" alt="" width="546"><figcaption></figcaption></figure>

13. Next, select the listed **`users`** and click on **`Assign`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FKeVRwN9CLPEa0LF3jk5J%2Fimage.png?alt=media&#x26;token=79fa8f76-0f7d-4226-9b1c-977c4bb6b965" alt="" width="544"><figcaption></figcaption></figure>

14. After you assign the user, click **`Save and Go Back`** and then click **`Done`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FvpNe2OOX9689D3jIMdF8%2Fimage.png?alt=media&#x26;token=17df89d1-e6bb-4e34-8263-6309f829fec1" alt="" width="544"><figcaption></figcaption></figure>

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FLdHg8O2g7vxgHKeoQEm7%2Fimage.png?alt=media&#x26;token=7be71ac8-a8f2-4b75-9fdb-561c61c1205c" alt="" width="450"><figcaption></figcaption></figure>

### Step 3: Configuring SAML Connection in CodeScan <a href="#step-3-configuring-saml-connection-in-codescan" id="step-3-configuring-saml-connection-in-codescan"></a>

Once the application is created, you will need to enter the identity provider data from OKTA into CodeScan.

1. In **OKTA**, go to the **`Sign On`** tab and navigate to the **`SAML Signing Certificates`** section.
2. For **SHA-2**, click on **`Actions > Download Certificate`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F47Rrxd3zrtligYzAWl2S%2Fimage.png?alt=media&#x26;token=757d4bb1-1446-4a03-8cfb-e429329e27be" alt="" width="563"><figcaption></figcaption></figure>

3. Open the downloaded certificate in Notepad. You will need to copy the content of the certificate into the **`X509 Signing Certificate`** field of CodeScan SAML connection \[***Step 7.c** below*].
4. Click on the **`Actions > View IdP metadata`**.

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FpVhMPTTupuKwTynKaCkl%2Fimage.png?alt=media&#x26;token=b5c51b3d-b1c8-499f-a338-8b0bafd2cc2a" alt="" width="563"><figcaption></figcaption></figure>

5. A new tab will open, which displays the IdP metadata file in XML format.
6. In **CodeScan**, on the **`SAML`** page, go to **`Actions`** and click on **`Edit`**.<br>

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FNCiQ7kuMHXsTpeNrNG2H%2Fimage.png?alt=media&#x26;token=f5163804-3e4f-4a88-baa1-a1c3adb23802" alt=""><figcaption></figcaption></figure>
7. Enter the following values:

   * **`Provider Entity Id`**: Copy the **entityID** value and paste it into **`Provider Entity Id`** inside CodeScan.
   * **`Sign In URL`**: Copy the **SingleSignOnService Location** value and paste it into the **`Sign In URL`** inside CodeScan.

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F3Ulqf19xfYZuLhLNw7Le%2Fimage.png?alt=media&#x26;token=c3088ed2-c7cc-460c-aefd-61eebbdc0157" alt=""><figcaption></figcaption></figure>

   * Copy the content of the downloaded certificate \[*refer to **Step 2** above to download the certificate*] into the **`X509 Signing Certificate`** field of Codescan SAML connection.<br>

     <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F5ItPOdC8ViGGHO8jJddC%2Fimage.png?alt=media&#x26;token=69d9c9ec-5fd0-4cd8-a224-e764332c3d59" alt=""><figcaption></figcaption></figure>
8. Click **`Update`** on the CodeScan page.
9. The next step is to confirm your corporate domain to get the SSO working. You can confirm domain by raising a request via [Codescan Support](https://mailto:support@autorabit.com/).

### Step 4: Testing the Single Sign-On Configuration <a href="#step-4-testing-the-single-signon-configuration" id="step-4-testing-the-single-signon-configuration"></a>

1. Log out of the CodeScan Console, and then log back in using the **`Log in with SAML2`** option.\
   ![](https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FY1O6Ai4taK06XNm0ONiR%2Fimage.png?alt=media\&token=ae3d4c64-69fd-487b-859b-8a23abb19100)
2. Enter the corporate domain name you have configured when enabling SSO inside CodeScan in the **`Your Company email`** field. **For example**- *`autorabit.com`*
3. You should successfully redirect to the CodeScan **`Organization`** page after authentication.

Here is a sample document from OKTA on how to set up network zones that restrict access to apps registered in OKTA: <https://help.okta.com/oie/en-us/content/topics/security/network/network-zones.htm>.
