How to setup Ohif viewer, dcm4chee and keycloak

Hello! I’m seeking guidance on how to properly integrate the OHIF Viewer with Keycloak 23.0.6. I already have OHIF installed and a PACS setup (using WSL), and I’m looking to add security (login and password) to the viewer. I managed to install and run Keycloak on Docker, and here’s what I did in the viewer:

oidc: [
    {
      authority: 'http://localhost:7080/realms/ohif',
      client_id: 'ohif-viewer',
      redirect_uri: 'http://localhost:3000/',
      response_type: 'code',
      scope: 'openid',
      //post_logout_redirect_uri: '/logout-redirect.html',
    },
  ],

However, upon initiating OHIF at localhost:3000, I encounter the Keycloak login screen, but after successful login, a loop occurs where the URL loads http://localhost:3000 and also this URL: http://localhost:3000/?state=516d35530a7545b8895514e710393ccc&session_state=95a5052b-483c-40f9-9fd6-33b06beb5199&iss=http%3A%2F%2Flocalhost%3A7080%2Frealms%2Fohif&code=1bad81da-4c0e-4a1c-8bcd-15aa6e1685b5.95a5052b-483c-40f9-9fd6-33b06beb5199.945c8d99-d2a4-42a9-a422-634b1cdca822

It’s stuck in an infinite loop of this. Attached is a screenshot of the console:

I’d like to understand what I need to make this work. Do I need to use the recipe from the .recipe folder of OHIF? However, there’s no recipe for dcm4chee with Keycloak, only for Orthanc. I want only registered users on keycloak can access the ohif viewer

I really dont know if its a viewer, keycloak or Dcm4chee problem. I do not use dcm4chee secure version, could be that? But cant i have only a viewer secured with keycloak, without any pacs? for example

I managed to change the behavior. After logging in, it goes to this page.

I changed the routerBasename, thinking it could be a problem configuring routes between the app and keycloak.
It’s a black screen with no data, and the viewer/viewer path doesn’t exist, I don’t understand how it’s getting there.



If anyone can help me, I’ve been stuck on this for days, I have little knowledge of JavaScript which makes solving this even more difficult.

This does not work right now, but i will create a readme and recipe for this soon

We recently added several recipes for implementing authentication with Keycloak in OHIF. You can find them here: