Update Harbor OIDC after IDP host change #20550
|
I have a small self-hosted harbor instance connected to our IPD. I rarely log into Harbor as it's running smoothly and all workflows that involve Harbor are automated. A while ago I've changed my domain names, and had to move a bunch of services to another domain, including Keycloak which was configured as OIDC for Harbor. Unfortunately I've forgot to update Harbor's OIDC settings. I've had to restart Harbor today to make an upgrade, and now I get an error and can't access Harbor anymore. In the And trying to access the Harbor UI redirects to the Any idea how I can fix this within Harbor itself? Unfortunately I no longer have access to this domain. I suppose I could play with CoreDNS to fake it temporarily? Would be great if there was a way to inject/update the OIDC settings via the Helm chart values or temporarily disable it. Thanks 🙏 |
Replies: 3 comments 3 replies
|
Could you please try to login the Harbor using admin (db auth) and navigate to |
|
I was able to fix it by updating the values in the database. I only have one OIDC enabled, so this worked for me without additional filters. If you have multiple OIDC providers configured, you may need to add additional UPDATE properties SET v = 'https://new-keycloak.com/realms/main' WHERE k = 'oidc_endpoint';The UPDATE oidc_user set subiss = '263e62ef-399e-447c-98fb-17ac0b81fa74https://new-keycloak.com/realms/main' where subiss = '263e62ef-399e-447c-98fb-17ac0b81fa74https://old-keycloak.com/realms/main'; |
|
I ran into the same issue after changing only the Keycloak hostname (the realm and users remained the same). After updating Harbor's OIDC endpoint, existing users could no longer log in. Harbor attempted to create new user records and returned errors such as: The root cause is that Harbor stores OIDC identity in the When the Keycloak issuer URL changes (for example due to a hostname or realm URL change), the stored For a single OIDC provider, the following migration fixed the issue for all users: BEGIN;
UPDATE properties
SET v = 'https://<new-keycloak-host>/auth/realms/<realm-name>'
WHERE k = 'oidc_endpoint';
UPDATE oidc_user
SET subiss = REPLACE(
subiss,
'https://<old-keycloak-host>/auth/realms/<realm-name>',
'https://<new-keycloak-host>/auth/realms/<realm-name>'
)
WHERE subiss LIKE '%https://<old-keycloak-host>/auth/realms/<realm-name>';
COMMIT;This preserves each user's If multiple OIDC providers are configured, the update should be restricted with additional filtering to avoid modifying unrelated identities. |

I was able to fix it by updating the values in the database.
I only have one OIDC enabled, so this worked for me without additional filters. If you have multiple OIDC providers configured, you may need to add additional
WHEREclauses.The
subissfield in theoidc_usertable also needed updating: