SAML Single Sign On (SSO) into Jenkins using Shibboleth3


Jenkins SAML SSO app gives the ability to enable SAML Single Sign-On (SSO) for Jenkins. Here we will go through a guide to configure Single Sign On (SSO) between Jenkins and Shibboleth3. By the end of this guide, Shibboleth 3 users should be able to log in and register to Jenkins.

Pre-requisites

To integrate your Identity Provider (IDP) with Jenkins, you need the following items:

  • Jenkins should be installed and configured.
  • Jenkins Server is https enabled (optional).
  • Admin credentials are set up in Jenkins.

Download And Installation



  • Login to your Jenkins Admin Account.
  • SSO SAML Jenkins single sign on manage jenkins, Jenkins SAML SSO
  • Go to Manage Jenkins option from the left pane, and open Manage Plugins tab.
  • SSO SAML Jenkins single sign onmanage plugins, Jenkins SAML SSO
  • Search for Miniorange saml in the available tab.
  • SSO SAML Jenkins single sign onupload plugin, Jenkins SAML SSO
  • Download and install with a restart.
  • SSO SAML Jenkins single sign on install plugins, Jenkins SAML SSO

Step 1: Setup Shibboleth3 as Identity Provider

      • In conf/idp.properties, uncomment and set 'idp.encryption.optional' to true.
           eg. idp.encryption.optional = true
      • In conf/metadata-providers.xml, configure Service Provider like below.
      • <MetadataProvider xmlns:samlmd="urn:oasis:names:tc:SAML:2.0:metadata"
          id="miniOrangeInLineEntity" xsi:type="InlineMetadataProvider" sortKey="1">
          <samlmd:EntityDescriptor ID="entity" entityID="<SP-EntityID / Issuer from Service Provider Info tab in plugin.>"
            validUntil="2020-09-06T04:13:32Z">
            <samlmd:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="true"
            protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
              <samlmd:NameIDFormat>
                urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
              </samlmd:NameIDFormat>
            <samlmd:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
            Location="<ACS (AssertionConsumerService) URL from Step1 of the plugin under Identity Provider Tab.>"
              index="1" />
            </samlmd:SPSSODescriptor>
            </samlmd:EntityDescriptor>
        </MetadataProvider>

      • In conf/saml-nameid.properties, uncomment and set default NameID as Email Address like this
      • idp.nameid.saml2.default=urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress

      • In conf/saml-nameid-xml, search for shibboleth.SAML2NameIDGenerators. Uncomment the shibboleth.SAML2AttributeSourcedGenerator bean and comment all other ref beans.
      • <!-- SAML 2 NameID Generation -->
        <util:list id="shibboleth.SAML2NameIDGenerators">
          <!--<ref bean="shibboleth.SAML2TransientGenerator" /> -->
          <!-->ref bean="shibboleth.SAML2PersistentGenerator" /> -->
          <bean parent="shibboleth.SAML2AttributeSourcedGenerator"
          p:format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
          p:attributeSourceIds="#{ {'email'} }" />
        </util:list>

      • Make sure you have defined AttributeDefinition in conf/attribute-resolver.xml.
      • <!-- Note: AttributeDefinitionid must be same as what you provided in attributeSourceIds in conf/saml-nameid.xml -->
        <resolver:AttributeDefinitionxsi:type="ad:Simple" id="email" sourceAttributeID="mail">
          <resolver:Dependency ref="ldapConnector" />
          <resolver:AttributeEncoderxsi:type="enc:SAML2String" name="email" friendlyName="email" />
        </resolver:AttributeDefinition >

        <resolver:DataConnector id="ldapConnector" xsi:type="dc:LDAPDirectory" ldapURL="%{idp.authn.LDAP.ldapURL}"
          baseDN="%{idp.authn.LDAP.baseDN}" principal="%{idp.authn.LDAP.bindDN}"
          principalCredential="%{idp.authn.LDAP.bindDNCredential}">
          <dc:FilterTemplate>
            <!-- Define you User Search Filter here -->
            <![CDATA[ (&(objectclass=*)(cn=$requestContext.principalName)) ]]>
          </dc:FilterTemplate>

          <dc:ReturnAttributes>*</dc:ReturnAttributes>
        </resolver:DataConnector>

      • Make sure you have AttributeFilterPolicy defined in conf/attribute-filter.xml.
      • <afp:AttributeFilterPolicy id="ldapAttributes">
        <afp:PolicyRequirementRulexsi:type="basic:ANY"/>
          <afp:AttributeRuleattributeID="email">
            <afp:PermitValueRulexsi:type="basic:ANY"/>
          </afp:AttributeRule>
        </afp:AttributeFilterPolicy>

      • Restart the Shibboleth server.
      • You need to configure these endpoints in the miniOrange plugin.
      • IDP Entity ID https://<your_domain>/idp/shibboleth
        Single Login URL https://<your_domain>/idp/profile/SAML2/Redirect/SSO
        Single Logout URL https://<your_domain>/idp/shibboleth
        X.509 Certificate The public key certificate of your Shibboleth server

Step 2: Setup Jenkins as Service Provider

  • Open Manage Jenkins and select Configure Global Security.
  • SSO SAML Jenkins single sign on configure security, Jenkins SAML SSO
  • Set the Security Realm as miniorange SAML 2.0 and click on save button.
  • SSO SAML Jenkins single sign on security realm, Jenkins SAML SSO
  • Make sure that Enable Security checkbox is checked.
  • Choose miniorange SAML SSO from the manage Jenkins tab.
  • SSO SAML Jenkins single sign on security realm, Jenkins SAML SSO
SP Configurations
You can configure SP settings in IDP in 2 ways:

A. By uploading Metadata XML file

  • Click on Service Provider Metadata in SP Configuration section.
  • Metadata xml file will be downloaded.
  • Use this file to setup IDP.
B. Manual Configuration

  • To Configure SP Settings at IDP copy below URL and paste in respective fields at IDP end.
    • SP Entity ID: https://your-jenkins-domain
    • Audience URI: https://your-jenkins-domain
    • ACS URL: https://your-jenkins-domain/securityRealm/moSamlAuth
    • sso saml jenkins single sign on SP Configuration Jenkins
IDP Configuration

To Configure IDP enter the following details and press apply and save the settings.

  • IDP Entity ID
  • Single Sign On URL
  • Name ID Format
  • X.509 Certificate
  • sso saml jenkins single sign on idp Configuration Jenkins
  • You can either enter the metadata URL or the metadata file path.
  • sso saml jenkins single sign on idp Configuration Jenkins

User Profile Configuration

  • Select Username Case Conversion.
  • Enter the attribute name from IDP which corresponds to Username in Username Attribute textbox.
  • Enter the attribute name from IDP which corresponds to Email in Email Attribute textbox.
  • Select the checkbox Apply regex Pattern to the UserNameif the userID returned from SAML is not same as username of Jenkins.
  • Enter the regular expression in REGEX Pattern textbox. It will be applied on user ID from SAML Response and will convert it into the username same as Jenkins. For example, you can use regular expression ^.*?(?=@) to extract demo from username demo@example.com
  • sso saml jenkins single sign on User Profile Jenkins


Advanced Configurations

  • Select the SSO Binding Type.
  • Select the Create new user after SSO? to allow user creation through SAML.
  • Select Force Authentication.
  • To Add custom Attributes select Add option.
    • Set Attribute Name as the one set in IDP eg. lname
    • Set display name in user proprties as one you want it appear in jenkins user's config.xml file and in user's configure tab.
    sso saml jenkins single sign on Advanced Configuration Jenkins


SP Configurations
You can configure SP settings in IDP in 2 ways:

A. By uploading Metadata XML file

  • Click on Service Provider Metadata in SP Configuration section.
  • Metadata xml file will be downloaded.
  • Use this file to setup IDP.
B. Manual Configuration

  • To Configure SP Settings at IDP copy below URL and paste in respective fields at IDP end.
    • SP Entity ID: https://your-jenkins-domain
    • Audience URI: https://your-jenkins-domain
    • ACS URL: https://your-jenkins-domain/securityRealm/moSamlAuth
    • sso saml jenkins single sign on SP Configuration Jenkins
IDP Configuration

To Configure IDP enter the following details and press apply and save the settings.

  • IDP Entity ID
  • Single Sign On URL
  • Single Logout URL
  • Name ID Format
  • X.509 Certificate
  • sso saml jenkins single sign on idp Configuration Jenkins
  • You can either enter the metadata URL or the metadata file path.
  • sso saml jenkins single sign on idp Configuration Jenkins

User Profile Configuration

  • Select Username or Email for Login Jenkins account by:
  • Select Username Case Conversion.
  • Enter the attribute name from IDP which corresponds to Username in Username Attribute textbox.
  • Enter the attribute name from IDP which corresponds to Email in Email Attribute textbox.
  • Enter the attribute name from IDP which corresponds to full name in Full Name Attribute.
  • Select the checkbox Apply regex Pattern to the UserNameif the userID returned from SAML is not same as username of Jenkins.
  • Enter the regular expression in REGEX Pattern textbox. It will be applied on user ID from SAML Response and will convert it into the username same as Jenkins. For example, you can use regular expression ^.*?(?=@) to extract demo from username demo@example.com
  • sso saml jenkins single sign on User Profile Jenkins


Advanced Configurations

  • Select the SSO Binding Type.
  • Select the SLO Binding Type.
  • Select the Send Signed Request ? to send signed login and logout requests. Requests will be signed using public certificate from option Download SP Certificate in SP Configuration section.
  • Select the Create new user after SSO? to allow user creation through SAML.
  • Select Force Authentication.
  • Select the Update Attributes of Existing Users ? to update attributes of existing user's each time they sign in Jenkins through SSO.
  • To Add custom Attributes select Add option.
    • Set Attribute Name as the one set in IDP eg. lname
    • Set display name in user proprties as one you want it appear in jenkins user's config.xml file and in user's configure tab.
  • To assign default group to users created through SSO add group name in Assign group to new Users option. Multiple groups can be added using ,(Comma) separater
  • You can assign groups from IDP to users created through SSO by adding the name of the group attribute that contains the IDP groups in the SAML response in the Group Attribute field in the plugin configuration. You can find out the group attribute name by performing the test configuration from the test configuration button under the I will do manual configuration tab.
  • If Disable Default login option is enabled, any unauthenticated user trying to access the default Jenkins login page will get redirected to the IDP login page for authentication. After successful authentication, they will be redirected back to the Jenkins base URL.
  • Copy backdoor URL and save it for emergency.
  • sso saml jenkins single sign on Advanced Configuration Jenkins





Free Trial

If you don't find what you are looking for, please contact us at support-atlassian@miniorange.atlassian.net or raise a support ticket here.