RealmDeployDocs
GuidesSingle sign-on for apps

Keycloak SSO for Argo CD

Sign in to Argo CD with Keycloak over OpenID Connect, send Keycloak groups in a groups claim, and map them to Argo CD roles in argocd-rbac-cm.

Argo CD talks to Keycloak directly through its built-in OIDC support, without Dex. You set it up in the argocd-cm ConfigMap, keep the client secret in argocd-secret, and grant access by group in argocd-rbac-cm.

Checked against Argo CD 3.6 docs and Keycloak 26.8 on 25 November 2026.

Replace auth.example.com with your RealmDeploy hostname and acme with your realm. The examples use https://argocd.example.com for Argo CD and the argocd namespace.

Argo CD's Keycloak guide offers two setups:

  • Client authentication (below): a confidential client with a secret. Login works in the web UI.
  • PKCE: a public client without a secret. Choose it if people also sign in with the argocd CLI; see Use the argocd CLI.

In Keycloak

Create the client

Open Clients, choose Create client, and use these values:

SettingValue
Client typeOpenID Connect
Client IDargocd
Client authenticationOn
Authentication flowStandard flow only
Root URLhttps://argocd.example.com
Home URL/applications
Valid redirect URIshttps://argocd.example.com/auth/callback
Valid post logout redirect URIshttps://argocd.example.com
Web originshttps://argocd.example.com

Choose Save, then copy the secret from the Credentials tab.

Argo CD's Keycloak guide also sets Admin URL. Leave it empty. Keycloak uses that URL to call the app from your tenant, and outgoing connections from your tenant are closed by default. Argo CD does not need it.

Add a groups client scope

Keycloak has no built-in groups scope, so create one, as Argo CD's guide does:

  1. Open Client scopes and choose Create client scope.
  2. Enter the Name groups, keep Protocol on OpenID Connect, and choose Save.
  3. On its Mappers tab, choose Configure a new mapper and pick Group Membership.
  4. Fill it in and choose Save:
FieldValue
Namegroups
Token Claim Namegroups
Full group pathOff
Add to ID tokenOn
  1. Open the argocd client, go to its Client scopes tab, choose Add client scope, select groups, and add it as Default.

Then create a group, for example ArgoCDAdmins, under Groups and add your user to it.

In Argo CD

Store the client secret in argocd-secret under a key of your choice:

kubectl -n argocd patch secret argocd-secret \
  --patch='{"stringData": {"oidc.keycloak.clientSecret": "CLIENT_SECRET_FROM_KEYCLOAK"}}'

Then set url and oidc.config in argocd-cm:

argocd-cm.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-cm
  namespace: argocd
  labels:
    app.kubernetes.io/name: argocd-cm
    app.kubernetes.io/part-of: argocd
data:
  url: https://argocd.example.com
  oidc.config: |
    name: Keycloak
    issuer: https://auth.example.com/realms/acme
    clientID: argocd
    clientSecret: $oidc.keycloak.clientSecret
    requestedScopes: ["openid", "profile", "email", "groups"]
    refreshTokenThreshold: 2m
    logoutURL: https://auth.example.com/realms/acme/protocol/openid-connect/logout?id_token_hint={{token}}&post_logout_redirect_uri={{logoutRedirectURL}}

Apply it with kubectl apply -f argocd-cm.yaml, or edit the live object with kubectl -n argocd edit configmap argocd-cm. Keep the app.kubernetes.io/part-of: argocd label: Argo CD ignores ConfigMaps without it.

SettingMeaning
urlArgo CD's public address. Argo CD builds the callback https://argocd.example.com/auth/callback from it.
issuerYour realm. Argo CD reads the discovery document under it and checks the iss claim.
clientIDArgo CD also checks that the ID token's aud is this client ID, which is what Keycloak puts there.
clientSecret$oidc.keycloak.clientSecret tells Argo CD to read that key from argocd-secret.
requestedScopesIncludes groups. Because groups is a default scope on the client, Keycloak adds the claim either way.
refreshTokenThresholdArgo CD refreshes the token this long before it expires. Keep it below the token lifespan; Keycloak's default access token lifespan is 5 minutes.
logoutURLKeycloak's logout endpoint. Argo CD fills in {{token}} with the ID token and {{logoutRedirectURL}} with its own base URL, which must be in Valid post logout redirect URIs.

The login page now shows Log in via Keycloak.

Groups and roles

Argo CD reads the groups claim and matches it against g lines in argocd-rbac-cm:

argocd-rbac-cm.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-rbac-cm
  namespace: argocd
  labels:
    app.kubernetes.io/name: argocd-rbac-cm
    app.kubernetes.io/part-of: argocd
data:
  policy.default: role:readonly
  policy.csv: |
    g, ArgoCDAdmins, role:admin
SettingMeaning
g, ArgoCDAdmins, role:adminMembers of the Keycloak group ArgoCDAdmins get Argo CD's built-in role:admin.
policy.defaultThe role every signed-in user gets. Leave it out to give users without a matching group no access.
scopesWhich claims Argo CD checks for groups. It defaults to [groups], so you do not need to set it.

The group name in policy.csv must match the claim exactly. With Full group path off, the claim is ArgoCDAdmins. With it on, Keycloak sends /ArgoCDAdmins, and that is what you would have to write.

Use the argocd CLI

Argo CD's Keycloak guide says the CLI needs the PKCE setup. Change the client and the config like this:

In KeycloakValue
Client authenticationOff
Valid redirect URIshttps://argocd.example.com/auth/callback, https://argocd.example.com/pkce/verify and http://localhost:8085/auth/callback
PKCE Method (Settings tab, Capability config)S256

8085 is the CLI's default --sso-port. In argocd-cm, drop clientSecret and turn on PKCE:

argocd-cm.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-cm
  namespace: argocd
  labels:
    app.kubernetes.io/name: argocd-cm
    app.kubernetes.io/part-of: argocd
data:
  url: https://argocd.example.com
  oidc.config: |
    name: Keycloak
    issuer: https://auth.example.com/realms/acme
    clientID: argocd
    enablePKCEAuthentication: true
    requestedScopes: ["openid", "profile", "email", "groups"]
    refreshTokenThreshold: 2m
    logoutURL: https://auth.example.com/realms/acme/protocol/openid-connect/logout?id_token_hint={{token}}&post_logout_redirect_uri={{logoutRedirectURL}}

Then sign in from a terminal. The CLI listens on localhost:8085 and opens the browser:

argocd login argocd.example.com --sso --grpc-web

Test it

  1. Open https://argocd.example.com in a private window and choose Log in via Keycloak.
  2. Sign in as a member of ArgoCDAdmins. Open User Info in the left menu: it lists your groups, and you can change settings.
  3. Sign in as a user outside the group. With policy.default: role:readonly they can look but not change anything.
  4. To see the claims Argo CD receives, open the argocd client in Keycloak, go to Client scopes → Evaluate, pick the user and look at Generated ID token. Paste it into the JWT decoder.
  5. Log out. You land on Keycloak's logout and then back on Argo CD.

Common errors

ErrorCauseFix
Invalid parameter: redirect_uri on the Keycloak pageurl in argocd-cm and Valid redirect URIs differ.Set url to the public address and list https://argocd.example.com/auth/callback exactly. Check with the redirect URI matcher.
Logged in, but every action is deniedThe groups claim is missing or does not match policy.csv.Check the ID token in Client scopes → Evaluate. Turn off Full group path, or write the group with its leading slash.
invalid_request: Missing parameter: code_challenge_methodYou moved from client authentication to PKCE and the browser still has the old flow.Try a private window or clear the cookies, as Argo CD's guide suggests.
401 or a login loop after changing the configargocd-server still uses the old settings.Restart it: kubectl -n argocd rollout restart deployment argocd-server.
invalid_clientWrong secret, or the key in argocd-secret does not match $oidc.keycloak.clientSecret.Patch the secret again. Look up other codes in the OAuth error lookup.
Invalid redirect uri on logoutArgo CD's base URL is not in Valid post logout redirect URIs.Add https://argocd.example.com. Build a test URL with the logout URL builder.

FAQ

Do I need Dex?

No. With oidc.config, Argo CD talks to Keycloak directly. Argo CD's docs suggest Dex for providers that do not support OpenID Connect, or for Dex's own connector features.

Can I keep the local admin account?

Yes. Argo CD's docs recommend disabling it once other users exist, with admin.enabled: "false" in argocd-cm. Make sure an SSO user has role:admin first.

Why does the session end after a few minutes?

The ID token expired and Argo CD could not refresh it. Keep refreshTokenThreshold below Keycloak's token lifespan.

Sources

On this page