Secure Jenkins with Keycloak SSO

This guide shows how to configure Jenkins to authenticate users via Keycloak using OpenID Connect (OIDC). It’s based on:

  • Jenkins: 2.492.3
  • Keycloak: 26.2.0
  • Plugin: OpenID Connect Authentication v4.494.v6b_f419104767

Prerequisites

  • Jenkins is publicly accessible at: https://jenkins.maksonlee.com
  • Keycloak is running at: https://keycloak.maksonlee.com
  • You have admin access to both Jenkins and Keycloak
  • You’ve created a Keycloak realm (e.g. maksonlee.com)

  1. Install OpenID Connect Plugin in Jenkins
  • Go to: Manage Jenkins → Plugin Manager → Available
  • Search for: OpenId Connect Authentication
  • Install the plugin and restart Jenkins

  1. Create Client in Keycloak for Jenkins

Basic Settings:

  • Navigate to: Clients → Create client
  • Fill in:
FieldValue
Client TypeOpenID Connect
Client IDjenkins

Click Next

Capability Configuration:

Enable only:

  • Standard Flow

Disable everything else:

  • Implicit Flow
  • Direct Access Grants
  • Service Accounts
  • Authorization

Click Next

Login Settings:

FieldValue
Root URLhttps://jenkins.maksonlee.com
Valid Redirect URIshttps://jenkins.maksonlee.com/*
Web Originshttps://jenkins.maksonlee.com
Post Logout Redirect URIhttps://jenkins.maksonlee.com

Click Save


  1. Get the Client Secret
  • Go to: Clients → jenkins → Credentials
  • Copy the Client Secret for use in Jenkins

  1. Configure Jenkins with Keycloak OIDC

Go to: Manage Jenkins → Security

Set the Security Realm:

Login with Openid Connect

Then fill in:

FieldValue
Client IDjenkins
Client Secret(paste from Keycloak)
Well-known endpointhttps://keycloak.maksonlee.com/realms/maksonlee.com/.well-known/openid-configuration
Advanced -> Override scopesopenid email profile

Advanced configuration → User fields

Jenkins FieldKeycloak Claim
User name field namepreferred_username
Email field nameemail
Full name field namename
Groups field namegroups (optional)

Click Save


  1. Test Login
  • Log out of Jenkins
  • You’ll be redirected to Keycloak for authentication
  • Once authenticated, you’ll be signed into Jenkins

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top