> ## Documentation Index
> Fetch the complete documentation index at: https://wundergraphinc-milinda-router-80-entity-caching-base-implem.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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/create-openid-connect-client.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=68b2ee1ecd70fcd3def424b3600b42d3" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/create-client-settings-overview.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=a0a56c8d071666ed8bb78e78c36045f6" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/client-authenticator-with-id-and-secret.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=7d364849fe122b2e134f5db66d1f8163" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/openid-and-saml-metadata-settings.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=806c704f1a181f7a4f9346aca0b80e0f" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/organization-settings-with-ai-rbac-scim.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=24eae240c731c9f9451bc80de8b50ae3" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/oidc-provider-configuration-form.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=c0694687e40600c55f2090eefa79a01c" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/group-to-role-mapping-dialog.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=e563d40a93f5b8196150655b7eab1985" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/oidc-provider-configuration-steps.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=70d25efe00d166fc11c2213228c96663" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/access-settings-for-redirect-urls.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=cfa1c538650b96e9d940dd58d16220e1" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/client-scope-with-no-mappers-configured.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=d47ba313857d5b378a3f21c6012c1d98" 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-milinda-router-80-entity-caching-base-implem/mCvXKvmPvxzBuLRH/images/studio/sso/group-membership-mapper-configuration.png?fit=max&auto=format&n=mCvXKvmPvxzBuLRH&q=85&s=9e17807ce14a41e3d916a394a23ad777" 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>
