> ## Documentation Index
> Fetch the complete documentation index at: https://wundergraphinc-ahmet-eng-8587-documentation-for-connect-cli.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-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/image-23.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=7b8eee1f5c371bd4f732db4d1df18581" width="2304" height="1401" data-path="images/studio/sso/image-23.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-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/image-24.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=80af6b839731b6d4c89d581ffff24d96" width="2304" height="1413" data-path="images/studio/sso/image-24.png" />
    </Frame>
  </Step>

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

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/image-25.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=7110e0f53c8855505d500d7a869523bc" width="2304" height="1166" data-path="images/studio/sso/image-25.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-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/image-26.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=0149eea4732afe2bb8ca82c2a6cc925a" width="1497" height="335" data-path="images/studio/sso/image-26.png" />
    </Frame>
  </Step>

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

  <Step>
    Click on **Connect.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/connect_oidc.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=a63e1ded8ec97a6b332920dd52cdcd55" width="2796" height="1902" data-path="images/studio/sso/connect_oidc.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-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/connect-oidc-dialog.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=038f856d1791872245c1311acbe39fad" width="2786" height="2122" data-path="images/studio/sso/connect-oidc-dialog.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-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/map-oidc-groups.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=9181a935f5e9c73a71b6fdba4c6fecd8" width="2774" height="1972" data-path="images/studio/sso/map-oidc-groups.png" />
    </Frame>
  </Step>

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

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/connect-oidc-success.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=7d2a36bf0f2d2be2c1d2bc3d16babe84" width="2784" height="1848" data-path="images/studio/sso/connect-oidc-success.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-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/image-31.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=0756208e4c0c2f856c3ae1fc82fadd7c" width="2304" height="1046" data-path="images/studio/sso/image-31.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-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/image-32.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=bd3ec394d44fbd1785865c7ec8dc73ce" width="2304" height="1400" data-path="images/studio/sso/image-32.png" />
    </Frame>
  </Step>

  <Step>
    Select **Group Membership.**

    <Frame>
      <img src="https://mintcdn.com/wundergraphinc-ahmet-eng-8587-documentation-for-connect-cli/4bDdzZZwotgzjNTa/images/studio/sso/image-33.png?fit=max&auto=format&n=4bDdzZZwotgzjNTa&q=85&s=27dd0eb3d103fa19377f53612115fe3c" width="1782" height="1600" data-path="images/studio/sso/image-33.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>
