# Setting up SSO for admins and endpoints

The Single Sign On (SSO) features allows multiple people at your company to securely log into and administer your Managed Nebula network, using your OpenID Connect (OIDC) identity provider. This means that there is no separate password for them to manage, and onboarding/offboarding employees is a snap. Additionally, you can set up SSO for endpoints, allowing users of your Managed Nebula network to authenticate with your identity provider. You can also limit the group of people who have access to Defined Networking directly in your identity provider. This guide will walk through the process of setting up SSO in Managed Nebula.

## Requirements

To use the SSO features of Defined Networking you will need:

- The ability to create a new application in your OIDC Identity Provider (IDP)
- The ability to set a TXT DNS record on your email domain, for endpoint SSO and for admins logging in with SSO from the login page
- A Defined Networking account

## Caveats

**Tab: Admin**

While administrators authenticating with SSO are able to perform most actions, they are unable to modify the account’s SSO configuration. For this, you will need to log in with a magic link and a [passkey or authenticator app](/docs/guides/securing-your-admin-sign-in/) as you do today. Your identity provider handles the second factor for admins who sign in with SSO, so enforce two-factor authentication there.
  

**Tab: Endpoint**

After disabling an SSO provider, existing sessions will continue to be valid and users will continue to have access to network resources unless their devices are [blocked](/docs/guides/blocking-and-unblocking-hosts/) or deleted.
  

## Configuration

Ready to set up SSO on your account? Let’s get started!

Admin and endpoint providers are set up the same way, but each has its own sign-in redirect URL. Pick the tab for the provider you're adding.

**Tab: Admin**

1. Log in to your Defined Networking account, open the [Single Sign-On page](https://admin.defined.net/settings/sso), and start adding an admin provider.

   2. Log in to your identity provider and create a new OIDC application. Set its sign-in redirect URL, which some providers call a callback URL or redirect URI, to:

       ```text
       https://admin.defined.net/auth/oidc-callback
       ```

       The provider form in the admin panel shows the same URL under “Sign-in redirect URL”. If asked to specify a grant type, choose “Authorization Code.” You may also need to explicitly allow the “email” OIDC scope. The screenshot below is an example of what this might look like within your IDP, though each provider will differ.

       ![Form showing our callback inputted into a field named "Sign-in Redirect URLs"](./give-the-identity-provider-our-callback.png)

   3. Find three pieces of information in your identity provider and copy them into the provider form in the admin panel: Client ID, Client Secret, and the Issuer URL.

       <figure>
         <Image src={addSsoAdmin} alt="Form for creating a new admin SSO integration that requires a Client ID, a Client Secret, and an Issuer URL, with an optional email domain" class="screenshot-shadow" />
       </figure>

   4. Pick the domain of your admins' email addresses, or add a new one. With a verified domain, admins can log in with SSO straight from the [login page](https://admin.defined.net/auth/login): they enter their work email and choose “Continue with SSO”. Without a domain, admins can only log in with SSO through your organization's Sign-on URL.

   5. Click “Save”. If you picked a domain that isn't verified yet, we'll continue to domain verification. In your DNS provider, create a new TXT record with a name and value that matches the values provided, then click “Verify”. Once the domain is verified, you'll be prompted to enable the provider.

       <figure>
         <Image src={addSsoEndpointVerifyDomain} alt="Page that shows instructions for adding a TXT DNS entry to a domain for ownership verification" class="screenshot-shadow" />
       </figure>

       DNS changes can take anywhere from 15 minutes to 24 hours to propagate to us, so you can click “Verify later” and come back. Until the domain is verified, the provider shows as pending verification and can't be enabled. Pick “Verify domain” from its menu to return to the DNS instructions.

       <figure>
         <Image src={ssoAdminPendingVerification} alt="Admin identity provider for example.com, pending verification, with its menu open showing Edit, Verify domain, and Delete" class="screenshot-shadow" />
       </figure>

   6. Enable the provider. If you skipped the prompt to enable it, pick “Enable” from the provider's menu. Once enabled, it's ready to accept logins, and its card shows how your admins log in.

       <figure>
         <Image src={ssoAdminDetails} alt="Enabled admin identity provider for defined.net, explaining that admins log in from the login page with their defined.net email or with the Sign-on URL shown below" class="screenshot-shadow" />
       </figure>

   7. To verify your setup, open the login page in a private browser window, enter your email address, and choose “Continue with SSO”. If you didn't add a domain, use the Sign-on URL listed on the provider instead. Complete the sign-in. After landing back in your Defined Networking account you will be able to see the authentication in your logs, just like any other authentication!

       <figure>
         <Image src={ssoAdminAuditLogs} alt="Audit logs filtered to Admin SSO, showing an admin creating, editing, and deleting the identity provider, and another admin authenticating successfully using SSO" class="screenshot-shadow" />
       </figure>

    **Tab: Endpoint**

1. Log in to your Defined Networking account, open the [Single Sign-On page](https://admin.defined.net/settings/sso), and start adding an endpoint provider.

   2. Log in to your identity provider and create a new OIDC application. Set its sign-in redirect URL, which some providers call a callback URL or redirect URI, to:

       ```text
       https://auth.defined.net/auth/oidc-callback
       ```

       The provider form in the admin panel shows the same URL under “Sign-in redirect URL”. If asked to specify a grant type, choose “Authorization Code.” You may also need to explicitly allow the “email” OIDC scope. The screenshot below is an example of what this might look like within your IDP, though each provider will differ.

       ![Form showing our callback inputted into a field named "Sign-in Redirect URLs"](./give-the-identity-provider-our-callback.png)

   3. Find three pieces of information in your identity provider and copy them into the provider form in the admin panel: Client ID, Client Secret, and the Issuer URL.

       <figure>
         <Image src={addSsoEndpointConnectionDetails} alt="Form for creating a new SSO integration that requires a Client ID, a Client Secret, and an Issuer URL, there's more info needed further down the page" class="screenshot-shadow" />
       </figure>

   4. Scroll down and add the domain name for the email addresses allowed to auth with your IDP. Select a network if you have more than one, and choose a role to assign or create a new one for endpoint devices. You can also choose to adjust the amount of time that users will stay logged in, we've chosen a default of 16 hours to allow for a full workday of access.

       <figure>
         <Image src={addSsoEndpointAccessConfig} alt="Form for creating a new SSO integration scrolled down to access config that allows selecting a domain, a network, a role, and an auth validity window" class="screenshot-shadow" />
       </figure>

   5. Click “Save” and we'll continue to domain verification. In your DNS provider, create a new TXT record with a name and value that matches the values provided, then click “Verify”. It may take anywhere from 15 minutes to 24 hours for your DNS changes to propagate to us, so you can click “Verify later” and come back.

       <figure>
         <Image src={addSsoEndpointVerifyDomain} alt="Page that shows instructions for adding a TXT DNS entry to a domain for ownership verification" class="screenshot-shadow" />
       </figure>

   6. Once the domain is verified, enable the provider from the main Single Sign-On page.

       <figure>
         <Image src={addSsoEndpointVerifiedDomain} alt="Page that shows a verified domain and a disabled endpoint SSO config" class="screenshot-shadow" />
       </figure>

       <figure>
         <Image src={ssoEndpointDetails} alt="Enabled endpoint identity provider for example.com, showing its network, authentication validity, issuer URL, and client ID" class="screenshot-shadow" />
       </figure>

   7. To verify your setup, open DNClient Desktop, click “Join network”, and then "Authenticate with email" in the window that pops open. In the browser window that opens, enter your email address you will use to authenticate with your IDP. We'll redirect you to login, and after you get a successful login screen, you should see the host details in the context menu for DNClient Desktop, and a new host that contains your email address in the host name in the admin panel.

       <figure>
         <Image src={ssoEndpointLoginForm} alt="Login form with email filled in" class="screenshot-shadow" />
       </figure>

       <figure>
         <Image src={ssoEndpointHostEnrollSuccess} alt="Success screen showing the host's name, network name, and ip address" class="screenshot-shadow" />
       </figure>

    Congratulations on configuring SSO for your Managed Nebula network!

## Identity provider-specific instructions

### Google Workspaces

Setting up OIDC for Google Workspaces is not intuitive and runs the risk of accidentally opening your Defined Networking account to anyone with a Google email address, so we will address it here in detail.

1. [Create a new project](https://console.cloud.google.com/projectcreate) in your Google Developers Console, after logging in as an administrator.

2. Open the [Credentials](https://console.developers.google.com/apis/credentials) page in the Google API Console and choose the project you just created in the upper left corner (if not already selected).

3. Click the "Configure consent screen" button, then "Get started".

   1. Enter any app name you like, for instance, "Defined Networking SSO". You may also need to provide an email address for your SSO users to contact if they have trouble logging in.
   2. IMPORTANT: Choose "Internal" as the audience, which will limit login to only those users in your organization.

   ![Google app configuration showing the Internal audience selected](./google-internal.png)

   3. Finish setting up the consent screen and save.

4. Return to the [Credentials](https://console.developers.google.com/apis/credentials) page and click the "+ Create Credentials" button, and choose "OAuth client ID" from the dropdown.

![Screenshot of Google API console, showing the addition of an OAuth client ID](./google-create-credentials.png)

5. Pick "Web application" and give it a name like "Defined Networking Admin".

6. Underneath "Authorized redirect URIs", click the "+ Add URI" button and enter the sign-in redirect URL for an admin provider:

   ```text
   https://admin.defined.net/auth/oidc-callback
   ```

   For an endpoint provider, enter `https://auth.defined.net/auth/oidc-callback` instead.

7. Click the "Create" button

8. You will be shown a **Client ID** and a **Client secret**. These should be entered in their respective fields in the [SSO setup](https://admin.defined.net/settings/sso) page of the Managed Nebula admin panel, along with the **Issuer URL** of `https://accounts.google.com`. For **Domain**, pick your Google Workspace email domain.

9. Finally, save the Managed Nebula SSO configuration. If the domain isn't verified yet, add the TXT record as described in [Configuration](#configuration) above. Once the domain is verified and the provider is enabled, admins can log in from the [login page](https://admin.defined.net/auth/login) by entering their work email. To test it out, open the login page in a private browser window. Without a domain, admins log in with the organization-specific Sign-on URL shown on the page instead.

As always, feel free to [contact us](https://admin.defined.net/support/contact) if you have any difficulty or questions.
