Keycloak and Harbor OIDC single sign-on

Harbor users can sign in through Keycloak over OIDC, but Docker and Helm need a per-user CLI secret, and the switch from database auth has a hard precondition. This page covers the setup, claims, and failure points.

On this page

Harbor OIDC single sign-on with Keycloak: what the integration does

A platform team that wants Harbor users to sign in through Keycloak instead of local Harbor accounts can use Harbor's documented OIDC authentication mode. Harbor supports OIDC providers such as Keycloak, and it creates no local accounts for users who sign in that way. The switch is one-way in practice: Harbor allows the move from database authentication to OIDC only when no local users other than admin exist, so the planning work starts before anyone is switched over.

For administrators, the change moves identity out of Harbor. Harbor no longer handles self-registration, creating or deleting users, or changing and resetting passwords for OIDC users, so those tasks happen in Keycloak. Group membership arrives through a custom group claim in the ID token, and one OIDC admin group can be mapped to Harbor administrator rights. Your team must decide which Keycloak groups carry project and administrator roles, and confirm that the group claim is present in the tokens Harbor receives. The Harbor OIDC authentication guide sets out these settings and should be read alongside the Keycloak client configuration.

End users sign in to the Harbor web interface through the Keycloak login page. CLI users are different. Docker and Helm clients cannot follow OIDC browser redirects, so each Harbor user gets a CLI secret from their user profile and uses it as the password for docker login or helm registry login. That secret stays valid while Harbor can refresh the underlying token, which depends on the offline_access scope being granted. Plan for this in the Keycloak client scopes and in user guidance, because a CLI secret that stops working usually surfaces as a failed pipeline rather than a sign-in prompt.

What you need before configuring Keycloak and Harbor

Harbor OIDC sign-in depends on decisions made in both systems before anyone clicks through a login. The cards below cover the versions, transport security, Keycloak client and claims, admin access and the local user inventory that together determine whether the switch succeeds.

Keycloak release in use

Record the exact Keycloak version you will run. The current release is 26.8.1, published October 13, 2026. Since Keycloak 26.0, minor releases can carry opt-in breaking changes, so pin the version in your change record and read the upgrade notes for that line before you build the client. Confirm that the Harbor OIDC documentation for your chosen Harbor release lists your Keycloak version as supported.

Keycloak docs

Harbor release in use

Pick the Harbor line you will run and confirm its OIDC behavior in the documentation for that exact release. Harbor v2.15.4 was the latest stable release as of October 9, 2026. Note that v2.15.2 changed the bundled internal database and cache, and v2.15.3 introduced breaking changes to webhooks and content trust, so plan any upgrade separately from the authentication switch and take a backup first.

Harbor releases

HTTPS on both hostnames

Keycloak and Harbor both need TLS on their public hostnames, and the Harbor external URL must match what Docker and Helm clients use. Redirect URIs, the issuer and the token endpoints are all compared against these hostnames, so a mismatch shows up as a failed login. Confirm certificate chains are trusted by every CLI host and CI runner, because a Docker client that rejects the certificate will fail to obtain a CLI secret login.

Confidential client and group mapper

Create a confidential client for Harbor in an existing realm, with a client secret stored in your secrets manager. Add a group membership mapper to the ID token so Harbor receives a group claim. Harbor needs that claim to assign group-based access and the admin group, so test it by decoding a sample ID token for a test user before you configure Harbor. Make sure the group names are stable identifiers your administrators will recognize.

Harbor admin group plan

Decide which Keycloak group will map to Harbor administrator rights before the switch. Harbor allows one OIDC admin group, so that group should be small, owned by a named team and reviewed on a schedule. Confirm who keeps membership of that group and how membership changes are approved, because anyone in it can administer the registry. Plan a local break-glass admin account for recovery if Keycloak is unavailable.

Inventory of local Harbor users

Harbor allows the switch from database authentication to OIDC only when no local users other than admin exist. List every local account, confirm each person has a matching Keycloak identity, and remove or migrate accounts that do not. Once OIDC is active, Harbor does not create, delete or reset local passwords, so this inventory must be complete before you start. Keep a record of the removed accounts for your access review.

Harbor OIDC docs

How to configure Harbor to sign in through Keycloak

This sequence takes a Harbor instance from database authentication to OIDC sign-in through a Keycloak confidential client, with group-based admin rights and a CLI secret for Docker and Helm. Each step ends with a check you can run before moving on.

  1. Back up Harbor and confirm version changes

    The platform team takes a full backup of the Harbor database and registry storage before changing authentication. If you are upgrading from 2.14 or earlier, read the release notes for the bundled internal database and cache changes first, since v2.15.2 moves the bundled database from PostgreSQL 15 to PostgreSQL 18 on container startup and replaces Redis with Valkey, and the notes recommend a backup and a reindexdb run if index problems appear. Done when the backup restores to a test environment and the target Harbor version is running cleanly. Confirm the upgrade path with your own environment before you start.

  2. Confirm only the admin account is local

    Harbor allows the switch from database authentication to OIDC only when no local users other than admin exist. Query the user list in the Harbor administration console, or through the REST API, and record every local account. Move any service or human accounts you still need to a plan for OIDC users or remove them after confirming they are unused. Done when the list shows admin as the only local account. Harbor creates no local accounts for OIDC users, so this list is the last chance to catch an account that would block the switch.

  3. Create the Keycloak confidential client

    In the Keycloak realm your organization uses, create an OpenID Connect client with client authentication enabled, so it gets a client secret. Set the valid redirect URI to the Harbor callback path on your external URL, which the Harbor OIDC guide specifies, and restrict web origins to the same host. Keep the client in the realm that already holds your workforce users. Done when the client shows a generated secret under its credentials tab and the redirect URI matches your Harbor external URL exactly, including scheme and port.

  4. Add the group claim to the ID token

    Harbor reads group membership from a custom group claim in the ID token, so Keycloak must send one. Add a Group Membership mapper to the client's dedicated scope, set the token claim name to the name you will configure in Harbor, and enable it for the ID token. Choose full group path or short names deliberately, because the admin group value in Harbor must match what Keycloak emits. Done when a test login returns an ID token containing the group claim with the expected group values, which you can check in the token view of the client scope evaluation tool.

  5. Request the offline_access scope

    Harbor needs a refresh token to keep the CLI secret valid for Docker and Helm clients, and Keycloak issues one only when the client requests offline_access. Make sure the scope is assigned to the client as an optional or default client scope, and that your users are allowed to consent to it if consent is enforced in your realm. Done when a test authorization returns a refresh token alongside the ID token. Without this scope, the CLI secret stops working once the access token it was tied to expires.

  6. Set the OIDC endpoint, client and admin group in Harbor

    In the Harbor administration console, open the authentication settings and switch the auth mode to OIDC. Enter the Keycloak realm issuer URL as the OIDC endpoint, the client ID and client secret from step three, and the group claim name from step four. Set one OIDC admin group to grant Harbor administrator rights, using the exact value Keycloak emits. Confirm the OIDC scope list includes openid, profile, email, and offline_access. Done when Harbor saves the settings without an endpoint error and the Keycloak login button appears on the sign-in page.

  7. Test sign-in and the CLI secret

    Sign in to Harbor as a non-admin test user through Keycloak, then confirm the user has the project roles you expect and no administrator rights. Sign in as a member of the admin group and confirm administrator access. Open the test user's profile, copy the CLI secret, and run docker login against the Harbor host with the Keycloak username and that secret. Helm can use the same secret with helm registry login. Done when both docker login and helm registry login succeed, and the admin and non-admin accounts show the rights their groups should grant. Confirm the admin account still works for recovery before closing the change.

How browser and CLI sign-in reach Harbor through Keycloak

The diagram starts in two places: a user's browser redirected to Keycloak, and a Docker or Helm client that sends the username and the per-user CLI secret from the Harbor user profile. Keycloak issues the ID token with the group claim, and Harbor maps those groups to project roles and the single OIDC admin group. The offline_access refresh path is the link to check, because it is what keeps the CLI secret valid while Harbor can refresh the token.

Browser OIDC redirect and Docker or Helm CLI login both reach Harbor through Keycloak group claims.

Which Keycloak claims and scopes map to Harbor roles

This table pairs each Keycloak element with the Harbor setting that consumes it and the job it does. Read it as a checklist for the client and mapper configuration, then confirm the exact claim names and setting labels against the Harbor OIDC documentation for the release you run. Group-based admin and project access only works when the group claim reaches Harbor in the ID token.

Keycloak elementHarbor settingPurpose
Username claim (for example, preferred_username)OIDC username claim settingSets the Harbor username for each signed-in user. Pick a stable, unique value, because changing it later can create a second account for the same person.
Email claim (for example, email)OIDC email claim settingSupplies the email address Harbor associates with the user. Confirm the claim is mapped and populated for every user who signs in.
Custom group claim in the ID tokenOIDC group claim settingCarries the user's group membership to Harbor. Without this claim present in the ID token, Harbor cannot assign group-based roles, so test it with a sample login first.
Group that grants administrator rightsOIDC admin group settingNames one group whose members receive Harbor administrator rights. Keep this group small and tightly governed, and confirm the group name matches the Keycloak group path exactly.
offline_access scopeRequested scope for the OIDC clientAllows Harbor to refresh tokens so the CLI secret stays valid. Without it, CLI logins fail once the initial token expires.
Per-user CLI secretUser profile CLI secret (used as password)Gives Docker and Helm a password-like credential because those clients cannot follow OIDC redirects. Each user generates and rotates their own, and it must be treated as a credential.

Browser sign-in versus CLI secret for Docker and Helm

Console users open the Harbor web interface, select the sign-in option that uses OIDC, and are redirected to Keycloak to authenticate. Harbor does not hold a password for them and creates no local account, so their identity and group membership come from the token Keycloak issues. Harbor expects the group claim to be present in the ID token; without it, the user lands in Harbor with no project roles beyond what their account already carries. Because OIDC mode does not offer self-registration or password resets in Harbor, any password or MFA recovery happens in Keycloak.

  • Redirect flow: The browser completes the standard redirect to Keycloak and back to Harbor, so the user needs a working browser session on the Keycloak realm.
  • Group claim: Project roles follow the groups in the token, so a missing or renamed group claim silently removes access.
  • Session expiry: When the refresh fails, Harbor asks the user to sign in again through Keycloak instead of continuing the session.
  • Password recovery: Resets and MFA enrollment happen in Keycloak, not in Harbor.
  • Local admin: Keep the database-authenticated admin account documented for recovery if OIDC sign-in fails.

Check that a test user in each group sees the expected projects after a fresh sign-in, and that a forced session expiry returns them to Keycloak rather than to an error page.

Why switching from database auth needs an empty user table

Harbor allows the switch from database authentication to OIDC only when no local users other than the built-in admin exist. Plan the switch as a user migration first and a configuration change second. Start by inventorying every local account in the Harbor user list, including accounts that were created for CI jobs, former staff and test users. For each one, record the projects it owns, the project memberships it holds, and any robot accounts or CLI secrets that its automation depends on. Those three groups decide what happens to the account, and they are the items most likely to be missed because they live in different parts of the interface.

For each inventoried account, decide one of three outcomes before the cutover: the person will sign in again through Keycloak with the same username and their memberships recreated through group claims, the project will be transferred to an owner who already has an OIDC identity, or the project will be archived or deleted after its images are exported or replicated. Robot accounts are not user accounts in the same sense, so confirm in the Harbor documentation for your release how they behave when authentication mode changes, and plan to recreate their credentials and update every pipeline that uses them. Agree the mapping with the project owners, because a membership that is not mapped to a Keycloak group will silently stop granting access after the switch.

The planning must finish before the cutover because Harbor will not switch while local users remain, and because the OIDC mode removes the ability to create, reset or delete users inside Harbor. Anything left unplanned at that point must be fixed by an administrator working around the new sign-in path. Confirm the exact steps, the handling of robot accounts and the admin recovery path against the OIDC documentation for the Harbor release you run, and rehearse the switch in a non-production instance that has a copy of your user table.

Security settings that protect Harbor and Keycloak together

Harbor trusts whatever Keycloak asserts about group membership, so the two systems share one security boundary. The cards below cover the transport, client, access, recovery and credential decisions that keep that boundary intact, plus the logging needed to see who signed in and when.

Serve both systems over TLS

Put Keycloak and Harbor behind HTTPS endpoints with certificates your team manages. Keycloak's production guidance calls for TLS on all communication and a reverse proxy with path restrictions, and it recommends serving the admin console on a different hostname or context path from public frontend URLs. Check that the redirect URIs Harbor registers in Keycloak use the exact HTTPS addresses users reach, because a mismatch breaks sign-in and can hide a misconfigured proxy.

Keycloak production guide

Use a confidential client with a stored secret

Create the Harbor client in Keycloak as a confidential client so the client secret is required at token exchange. Store that secret in your secrets manager or the Harbor deployment's secret configuration, never in Git, Helm values committed to a repository or a shared wiki. Confirm the secret is rotated through Keycloak and Harbor together, since a rotation on one side without the other stops all sign-ins.

Limit the Harbor admin group

The OIDC admin group you configure in Harbor grants full Harbor administrator rights, so membership in that Keycloak group is effectively root access to the registry. Keep the group to a small named set of people, make membership changes go through an approval step in your identity process, and review it on a fixed schedule. Use a separate group for ordinary project members so that routine access never depends on the admin group.

Admin group in OIDC mode
1

Keep and document a local Harbor admin

Once Harbor runs in OIDC mode it creates no local accounts for users, so a broken Keycloak, expired certificate or wrong redirect URI can lock everyone out. Keep the built-in admin account working, store its credentials in a sealed location with named custodians, and test that you can sign in with it before go-live. Write the recovery steps down, including how to reach Keycloak's admin console, so an operator can follow them under pressure.

Treat CLI secrets as credentials

Each Harbor user's CLI secret is a long-lived password for Docker and Helm, and it stays valid while Harbor can refresh the token, which depends on the offline_access scope. Define a rotation rule, a revocation step for leavers and a way to reset a secret when a laptop is lost. Ask Harbor and your identity team to confirm how a disabled Keycloak user's CLI access is cut off, because a secret that still works after offboarding is a common gap.

Enable Keycloak logging and metrics

Decide which Keycloak events your security team needs, such as failed logins and admin changes, and confirm they are stored where you can search them. If you use Prometheus, start Keycloak with metrics enabled so the management endpoint at /metrics exposes data for dashboards and alerts. Restrict access to that endpoint, because metrics can reveal operational detail about your identity service.

Keycloak metrics guide

Common Harbor and Keycloak sign-in failures and fixes

This table pairs each common symptom with its likely cause and fix when Harbor signs users in through Keycloak. Start from the symptom column, check the cause against your realm and Harbor settings, then apply the fix and retest with a fresh sign-in. Most failures trace back to the group claim, the offline_access scope, or the user table left from database authentication.

SymptomLikely causeFix
Signed-in user belongs to no Harbor groupThe ID token has no group claim, so Harbor cannot read group membershipAdd a group membership mapper to the Harbor client in Keycloak that emits a groups claim in the ID token, then have the user sign in again so a new token is issued
User signs in but lacks Harbor administrator rightsThe OIDC admin group is set in Harbor, but the group name does not match the claim value exactly, or the user is not in that groupCompare the admin group name in Harbor with the value in the groups claim, correct any difference in case or path, confirm group membership in Keycloak, then sign out and back in
Docker or Helm login fails after a Keycloak password changeThe CLI secret is tied to the user's token refresh, and a password change or session reset in Keycloak can invalidate itHave the user generate a new CLI secret from their Harbor user profile and update the Docker credential store or Helm registry login with it
CLI secret stops working once the refresh token expiresThe offline_access scope was not requested, so Harbor cannot refresh the token behind the CLI secretAdd offline_access to the scopes Harbor requests from Keycloak, have affected users generate a new CLI secret, and retest a Docker push or Helm pull
Redirect URI mismatch error at sign-inThe valid redirect URI in the Keycloak client does not match the Harbor external URL exactly, including scheme, host, port and pathSet the Keycloak client redirect URI to the exact Harbor callback address, confirm the external URL in Harbor matches it, and check any reverse proxy rewrites
Switch from database authentication is blockedHarbor allows the switch to OIDC only when no local users other than admin exist, so a leftover local account stops itIdentify each local user, confirm which accounts are still needed, remove or migrate them so only admin remains, then retry the switch
Users can sign in but cannot create or change local passwordsOIDC mode does not support self-registration, user creation or deletion, or password changes inside HarborManage identities in Keycloak instead, and tell users to change passwords through Keycloak rather than in Harbor

What buyers ask before a Harbor OIDC project

How much effort does Keycloak and Harbor OIDC single sign-on take?

The effort depends mostly on three things: how many Harbor users already have local accounts, how your groups are designed, and how many people use Docker or Helm from the command line. Harbor only accepts a switch from database authentication to OIDC when no local users other than admin exist, so cleaning up local accounts is often the first task. Group design comes next, because Harbor needs a custom group claim in the ID token and one OIDC admin group to grant administrator rights. CLI users add work because each one needs a CLI secret from their profile and must be tested with Docker or Helm, which cannot follow OIDC redirects. Ask any partner to size the work from your user count, group model and CLI usage in a written scope.

Can our own team set up Harbor OIDC without outside help?

Yes, if your team already administers Keycloak and Harbor and can test CLI flows end to end. The configuration itself is mostly settings in Keycloak (a client, a group claim and the offline_access scope) and in Harbor's OIDC authentication screen. The harder part is verification: confirming that a browser sign-in works, that group membership maps to the right Harbor roles, that the admin group grants administrator rights, and that a Docker login and a Helm push still work with a CLI secret. If nobody on your team has tested those CLI paths, an outside partner can take that step within a fixed scope.

What does the work need from our side?

Plan for four inputs before work starts. You need access to the Keycloak realm with rights to create clients, mappers and groups. You need a Harbor administrator who can change authentication settings and who can approve the switch away from local accounts. You need a test user set that covers administrators, normal developers and at least one CLI user, so each path can be checked before production users are affected. You also need a change window, because users who depend on local credentials will be unable to sign in once the switch is made. Confirm each input with your Keycloak and Harbor owners before scheduling.

Do we need to upgrade Harbor before adding OIDC?

This depends on the Harbor version you run today, so confirm it against the release notes for your current line and for the version you plan to move to. The Harbor project publishes separate release notes for each version, and recent releases include changes that affect operators, such as the upgrade of the bundled internal database and breaking changes to webhooks and content trust. Read those notes, check which upgrade steps apply to your install, and take a backup before any upgrade. Keep the OIDC change and any version upgrade in separate change windows where possible, so that a problem can be traced to one of them.

What should a fixed-scope quote for this integration cover?

A fixed-scope quote should follow directly from a written scope that names the systems and paths in use. Ask for it to list the Keycloak client and mapper configuration, the Harbor OIDC settings, the group claim and admin group design, the cleanup of local accounts, the CLI secret guidance for users, and the test plan covering browser sign-in, role mapping, Docker and Helm. It should also state the deliverables, the acceptance tests, what the customer must provide and what is excluded, such as Harbor upgrades, replication or scanner changes. DeployOpen agrees scope, deliverables and timelines in writing before work starts and gives a quote from that scope.

What happens to CLI access after the switch to OIDC?

Docker and Helm clients cannot follow OIDC redirects, so each Harbor user needs a CLI secret from their user profile to use as a password. The secret stays valid while Harbor can refresh the token, and Harbor needs the offline_access scope in Keycloak for that refresh to work. Plan how each user gets the secret, how it is stored on their workstation or in CI, and how you will handle users who leave or change groups. Test the full path with a Docker login and a Helm push before you tell users to switch, because a missing offline_access scope is the kind of problem that appears only after tokens expire.

How DeployOpen scopes and delivers the Harbor and Keycloak integration

DeployOpen plans, builds and documents the Keycloak client, group claim and Harbor OIDC settings inside your own infrastructure, so your identity and security teams can review each step. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Confirm which Harbor version and Keycloak release your environment runs, and whether Harbor is already in use with database authentication.
  • Inventory existing local Harbor users and agree how they are migrated, removed or kept as admin before the switch.
  • Define the group claim, the single OIDC admin group and the project roles each team needs in Harbor.
  • Agree how Docker and Helm users receive and rotate their CLI secrets, including offline_access token behavior.

How we build

  • Create the Keycloak client, redirect URIs, scopes and group claim mapper, and test them against a non-production Harbor first.
  • Configure Harbor OIDC settings and verify that the admin group grants administrator rights and no other group does.
  • Test sign-in through the web interface, then docker login and helm registry login using each user's CLI secret.
  • Check TLS on all endpoints, the reverse proxy path rules and that Harbor and Keycloak certificates are trusted by clients.

How we hand over

  • Deliver a configuration record covering Keycloak client settings, Harbor OIDC values and the group-to-role mapping.
  • Document the user onboarding steps, including how each user generates and replaces a CLI secret.
  • Provide a runbook for the empty-user-table prerequisite, a rollback plan and the backup steps to take before any Harbor upgrade.
  • Walk your platform and security teams through the setup and the operational checks they will repeat.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer covering Harbor and Keycloak changes.
  • Review each Harbor and Keycloak upgrade against the OIDC settings, group claims and CLI secret behavior before rollout.
  • Retest sign-in, group mapping and admin access after patches, certificate renewals or identity provider changes.
  • Agree in writing which items you need to confirm with the vendors or in your own environment before a quote is final.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.