> ## Documentation Index
> Fetch the complete documentation index at: https://wundergraphinc-auto-improve-queries-with-defer.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Keycloak

> Setting up SSO with Keycloak

### Steps to set Keyclaok as an OIDC identity provider

<Steps>
  <Step>
    Navigate to the **Clients** view within your Keyclaok Dashboard.
  </Step>

  <Step>
    Click on **Create Client**.
  </Step>

  <Step>
    Select OpenID Connect as the **Client Type, and** give the client a  **Client ID**and a  **Name**and then click on **Next.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/create-openid-connect-client.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=83726c8cce6a8534e7e57c2d87b274f9" alt="Create client form for OpenID Connect with general, capability, and login settings" title="Create OpenID Connect client" width="2304" height="1401" data-path="images/studio/sso/create-openid-connect-client.png" />
    </Frame>
  </Step>

  <Step>
    Enable **Client authentication,** then click on **Next** and then click on  **Save**on the next page**.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/create-client-settings-overview.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=e01cfea5bb94cfeba58c826ec02e664d" alt="Create client page in Cosmo Docs with client authentication on and authorization off" title="Create client settings overview" width="2304" height="1413" data-path="images/studio/sso/create-client-settings-overview.png" />
    </Frame>
  </Step>

  <Step>
    Navigate to the **Credentials** tab and then copy the **Client Secret.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/client-authenticator-with-id-and-secret.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=b6749c21d9f0953b76874d22c3ab0186" alt="Client Authenticator settings showing client ID, secret, and regenerate option" title="Client Authenticator with ID and secret" width="2304" height="1166" data-path="images/studio/sso/client-authenticator-with-id-and-secret.png" />
    </Frame>
  </Step>

  <Step>
    Navigate to the **Realm Settings** and then copy the link of **OpenID Endpoint Configuration.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/openid-and-saml-metadata-settings.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=5ab31377944505f290eb9bcb3da952cc" alt="OpenID and SAML metadata settings with user-managed access turned off" title="OpenID and SAML metadata settings" width="1497" height="335" data-path="images/studio/sso/openid-and-saml-metadata-settings.png" />
    </Frame>
  </Step>

  <Step>
    Navigate to the settings page on Cosmo.
  </Step>

  <Step>
    Click on **Connect.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/organization-settings-with-ai-rbac-scim.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=ed8450bbe9a72545fab583f68a553118" alt="Organization settings showing name, slug, and status of AI, RBAC, and SCIM features" title="Organization settings with AI, RBAC, SCIM" width="2796" height="1902" data-path="images/studio/sso/organization-settings-with-ai-rbac-scim.png" />
    </Frame>
  </Step>

  <Step>
    Give the connection a name, paste the **OpenID Endpoint Configuration** copied before, into the  **Discovery Endpoint,**and paste the **Client ID** and  **Client secret**copied before into the **Client ID** and  **Client Secret fields respectively,** and then click on **Connect.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/oidc-provider-configuration-form.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=25205a9b20db9108f1c59d8d963de935" alt="Connect OpenID Connect Provider form with fields for name, endpoint, and credentials" title="OIDC provider configuration form" width="2786" height="2122" data-path="images/studio/sso/oidc-provider-configuration-form.png" />
    </Frame>
  </Step>

  <Step>
    Configure the mapping between the roles in Cosmo and the user groups in Keycloak. The field **Group in the provider** can be populated with the name of the group or a regex to match the user groups. Once all the mappers are configured, click on **Save**.

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/group-to-role-mapping-dialog.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=fd079da7f22ce13ef5b8e075c772b159" alt="Group mapper configuration dialog linking provider groups to Cosmo roles" title="Group-to-role mapping dialog" width="2774" height="1972" data-path="images/studio/sso/group-to-role-mapping-dialog.png" />
    </Frame>
  </Step>

  <Step>
    Copy the sign-in and sign-out redirect URIs displayed in the dialog.

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/oidc-provider-configuration-steps.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=ef77e5070da8547933a9922bf0a5ffe7" alt="Steps to configure OIDC provider with sign-in and sign-out redirect URLs" title="OIDC provider configuration steps" width="2784" height="1848" data-path="images/studio/sso/oidc-provider-configuration-steps.png" />
    </Frame>
  </Step>

  <Step>
    Navigate back to the client created on Keycloak and populate the **Valid redirect URIs** and **Valid post Logout redirect URIs** with the above-copied sign-in and sign-out URLs respectively. Click on **Save**.

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/access-settings-for-redirect-urls.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=43db0f46c55b20881b3843b0d703be3d" alt="Access settings showing valid redirect and logout URLs fields" title="Access settings for redirect URLs" width="2304" height="1046" data-path="images/studio/sso/access-settings-for-redirect-urls.png" />
    </Frame>
  </Step>

  <Step>
    Navigate to the **Client Scopes** tab, click on the first client scope(usually would be \$\{**clientID}-dedicated**), and then click on **Configure a new mapper.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/client-scope-with-no-mappers-configured.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=aa644dcde4f77c65ac42bf57d37530be" alt="Client scope page showing dedicated mappers section with no mappers added" title="Client scope with no mappers configured" width="2304" height="1400" data-path="images/studio/sso/client-scope-with-no-mappers-configured.png" />
    </Frame>
  </Step>

  <Step>
    Select **Group Membership.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-auto-improve-queries-with-defer/lkonUAgtUmzaMhJ9/images/studio/sso/group-membership-mapper-configuration.png?fit=max&auto=format&n=lkonUAgtUmzaMhJ9&q=85&s=0bff2a808ce63cf918284cc2dc0907b4" alt="Configure new mapper dialog with Group Membership option for token mapping" title="Group membership mapper configuration" width="1782" height="1600" data-path="images/studio/sso/group-membership-mapper-configuration.png" />
    </Frame>
  </Step>

  <Step>
    Give the mapper a name, then populate the **Token Claim Name** with **"**ssoGroups**"** and then click on **Save.**
  </Step>

  <Step>
    Now you can assign users/groups to the application, and those users will be able to log into Cosmo using the URL provided on setting up the provider.
  </Step>
</Steps>
