====================
Updating your domain
====================

To update your Package Security Manager domain, you need to update the domain variables in both the ``.env`` and ``kc.yaml`` files:

#. Open a terminal and connect to your instance of Package Security Manager.
#. Enter to your installer directory by running the following command:

    .. code-block:: none

        # Replace <INSTALLER> with your installer directory
        cd <INSTALLER>

#. Make a copy of the current ``.env`` file for reference and/or recovery purposes:

    .. code-block:: none

        cp .env .env.old

#. Using your preferred file editor, open the ``.env`` file.
#. Update the ``DOMAIN`` variable to your new domain. 

    .. dropdown:: Example .env file
        :animate: fade-in
        :color: primary

        .. thumbnail:: ../../img/as_env_file_domain_change.png
            :align: center


#. Save your changes and close the file.
#. Enter your keycloak directory by running the following command:

    .. code-block:: none

        cd keycloak/

#. Using your preferred file editor, open the ``kc.yaml`` file.
#. Locate the ``clientId: repo-service`` section of the file and add the following line:

    .. code-block:: none

        # Replace URL with your Package Security Manager URL
        rootUrl: "<URL>"

    .. dropdown:: Example kc.yaml file
        :animate: fade-in
        :color: primary

        .. thumbnail:: ../../img/as_kc_yaml_file_domain_change.png
            :align: center

    .. note::

        If you have existing clients (tools) configured to use Package Security Manager instances using the old DNS name, you will need to update those clients as well.

#. Restart your pods and apply your changes by running the following commands:

    .. code-block:: none

        docker compose up --detach

#. Open a browser and :ref:`log in to the Keycloak administrative console <access_kc>`. 
#. Verify you are on the **dev** realm.
#. Select **Clients** from the left-hand navigation. 
#. Select the **repo-service** client.

    .. thumbnail:: ../../img/kc_dev_client_repo-service.png
        :align: center

#. Update the **Root URL** to your new domain.
#. Prepend the Valid redirect URIs path with your new domain. 
#. Click **Save**.

    .. thumbnail:: ../../img/kc_dev_repo-service_new_domain.png
        :align: center

.. tip:: 

    If Keycloak demands you also update the **Backchannel logout URL**, add your new domain to the field under **Logout settings**, then save your changes. Next, delete the entry you just made and attempt to save again. 

#. If you are using SSL, :doc:`update your certificates </admin/ssl>` to refer to your new domain.
#. You can now log in to Package Security Manager normally. 