================
Keycloak Upgrade
================

With the release of Data Science & AI Workbench 5.6, significant improvements have been made to our Keycloak implementation. For details, please see the `release notes <https://enterprise-docs.anaconda.com/en/latest/reference/release-notes.html>`_. 

Upgrading to Workbench 5.6 requires Keycloak configuration changes to access your instance. You'll need to add a service account with correct permissions to the ``anaconda-platform`` client, then add a protocol mapper to the ``roles`` client scope.

Enabling the service account
============================

After your upgrade to Workbench 5.6+ completes:
  
#. Open a browser and log in to your Keycloak admin panel using your existing Keycloak credentials. Your Keycloak admin panel can be found at ``https://<FQDN>auth/admin`` where ``<FQDN>`` is your Workbench fully qualified domain name.
#. Verify you are on the **anaconda-platform** realm.

   .. thumbnail:: ../../images/kc_anaconda_platform_realm.png
      :align: center
  
#. Select **Clients** from the left-hand navigation, then select **anaconda-platform** from the list of available clients. 

   .. thumbnail:: ../../images/kc_clients_anaconda_platform.png
      :align: center

#. Select the **Service accounts roles** checkbox under **Capability config**, then save your changes. 

   .. thumbnail:: ../../images/kc_client_config_service_account_roles.png
      :align: center

#. Select the new **Service accounts roles** tab that appears at the top of the page.
#. Click **Assign role**.

   .. thumbnail:: ../../images/kc_assign_service_account_roles.png
      :align: center

#. Open the filter dropdown menu and select **Filter by clients**.

   .. thumbnail:: ../../images/kc_role_filter_options.png
      :align: center

#. Search for the ``view-users`` role. 
#. Select the role, then click **Assign**.

   .. thumbnail:: ../../images/kc_assign_view_users_role.png
      :align: center

Adding the protocol mapper
==========================

#. Select **Client scopes** from the left-hand navigation, then select **roles** from the list of available client scopes.

   .. thumbnail:: ../../images/kc_roles_client_scope.png
      :align: center

#. Select the **Mappers** tab.
#. Open the **Add mapper** dropdown menu and select **By configuration**. 

   .. thumbnail:: ../../images/kc_add_protocol_mapper.png
      :align: center

#. Select **Audience**. 

   ..  thumbnail:: ../../images/kc_audience_mapper.png
       :align: center

#. Complete the fields and set the toggle switches as indicated:

    * **Name** - my-audience
    * **Included Client Audience** - anaconda-platform
    * **Add to ID token** - ``ON``
    * **Add to access token** - ``ON``

#. Click **Save**. 

   .. thumbnail:: ../../images/kc_create_protocol_mapper.png
      :align: center

Success! You can now log in to your instance from an existing account and use Workbench normally.
