|
| 1 | +--- |
| 2 | +id: troubleshoot-login |
| 3 | +title: "Troubleshooting login issues" |
| 4 | +sidebar_label: "Login issues" |
| 5 | +--- |
| 6 | + |
| 7 | +:::note |
| 8 | +Web Modeler Self-Managed is available to [enterprise customers](../../../../reference/licenses.md#web-modeler) only. |
| 9 | +::: |
| 10 | + |
| 11 | +Logging in to Web Modeler doesn't work as expected and shows an error or a blank page when accessing the application. |
| 12 | + |
| 13 | +To further debug this issue, check the [log output](docs/self-managed/modeler/web-modeler/configuration/logging.md) of the `modeler-restapi` and `modeler-webapp` services for errors and warnings. |
| 14 | + |
| 15 | +## Unique constraint violation |
| 16 | + |
| 17 | +When you try to log in to Web Modeler using Keycloak as an OIDC provider, you see an error message in the `modeler-restapi` logs similar to this: |
| 18 | + |
| 19 | +``` |
| 20 | +org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "users_email_key" |
| 21 | + Detail: Key (email)=(***************) already exists. |
| 22 | +``` |
| 23 | + |
| 24 | +### Ensure the Keycloak-managed user id didn't change |
| 25 | + |
| 26 | +Web Modeler uses the value of the `sub` (subject) claim in the JSON Web Token (JWT) issued by the configured OIDC provider (by default Keycloak) to identify users and correlate them with their data created in Web Modeler. |
| 27 | +It is important that this value doesn't change over time, for example when the user is deleted and re-created in Keycloak or re-imported from an external user directory, or when reinstalling/updating/switching Keycloak instances. |
| 28 | + |
| 29 | +If the `sub` claim value changes for an existing user, Web Modeler will try to create a new user record in its database for the user, which will lead to the error above when the user tries to log in. |
| 30 | + |
| 31 | +As a workaround, you can manually update the user ID in the Web Modeler database: |
| 32 | + |
| 33 | +1. Export the users from the **Keycloak database** to a CSV file. The following query can be used to select the relevant data: |
| 34 | + ```sql |
| 35 | + SELECT id, email |
| 36 | + FROM user_entity |
| 37 | + WHERE realm_id = 'camunda-platform' AND email IS NOT NULL; |
| 38 | + ``` |
| 39 | +2. Create a new table in the **Web Modeler database**: |
| 40 | + ```sql |
| 41 | + CREATE TABLE keycloak_users ( |
| 42 | + id varchar(255), |
| 43 | + email varchar(255) |
| 44 | + ); |
| 45 | + ``` |
| 46 | +3. Import the CSV file from **Step 1** into the new `keycloak_users` table. |
| 47 | +4. Update the user IDs by running the following query in the **Web Modeler database**: |
| 48 | + ```sql |
| 49 | + UPDATE users u |
| 50 | + SET iam_id = k.id |
| 51 | + FROM keycloak_users k |
| 52 | + WHERE k.email = u.email; |
| 53 | + ``` |
| 54 | +5. Verify that the login is working again. |
| 55 | +6. Delete the `keycloak_users` table: |
| 56 | + ```sql |
| 57 | + DROP TABLE keycloak_users; |
| 58 | + ``` |
0 commit comments