Jenkins

Tested Versions

Before You Begin

Important Reading

This section contains important elements that you should carefully consider before configuration of an OpenID Connect 1.0 Registered Client.

Common Notes

  1. The OpenID Connect 1.0 client_id parameter:
    1. This must be a unique value for every client.
    2. The value used in this guide is merely for readability and demonstration purposes and you should not use this value in production and should instead utilize the How do I generate a client identifier or client secret? FAQ. We recommend 64 random characters but you can use any arbitrary value that meets the other criteria.
    3. This must only contain RFC3986 Unreserved Characters.
    4. This must be no more than 100 characters in length.
  2. The OpenID Connect 1.0 client_secret parameter:
    1. The value used in this guide is merely for demonstration purposes and you should absolutely not use this value in production and should instead utilize the How do I generate a client identifier or client secret? FAQ.
    2. This string may be stored as plaintext in the Authelia configuration but this behaviour is deprecated and is not guaranteed to be supported in the future. See the Plaintext guide for more information.
    3. When the secret is stored in hashed form in the Authelia configuration (heavily recommended), the cost of hashing can, if too great, cause timeouts for clients. See the Tuning the work factors guide for more information.
  3. The configuration example for Authelia:
    1. Only contains an example configuration for the client registration and you MUST also configure the required elements from the OpenID Connect 1.0 Provider Configuration guide.
    2. Only contains a small portion of all of the available options for a registered client and users may wish to configure portions that are not part of this guide or configure them differently, as such it’s important to both familiarize yourself with the other options available and the effect of each of the options configured in this section by looking at the OpenID Connect 1.0 Clients Configuration guide.

Assumptions

This example makes the following assumptions:

  • Application Root URL: https://jenkins.example.com/
  • Authelia Root URL: https://auth.example.com/
  • Client ID: jenkins
  • Client Secret: insecure_secret

Configuration

Authelia

The following YAML configuration is an example Authelia client configuration for use with Jenkins which will operate with the application example:

configuration.yml
identity_providers:
  oidc:
    ## The other portions of the mandatory OpenID Connect 1.0 configuration go here.
    ## See: https://www.authelia.com/c/oidc
    clients:
      - client_id: 'jenkins'
        client_name: 'Jenkins'
        client_secret: '$pbkdf2-sha512$310000$c8p78n7pUMln0jzvd4aK4Q$JNRBzwAo0ek5qKn50cFzzvE9RXV88h1wJn5KGiHrD0YKtZaR/nCb2CJPOsKaPK0hjf.9yHxzQGZziziccp6Yng'  # The digest of 'insecure_secret'.
        public: false
        authorization_policy: 'two_factor'
        require_pkce: true
        pkce_challenge_method: 'S256'
        redirect_uris:
          - 'https://jenkins.example.com/accounts/authelia/login/callback'
        scopes:
          - 'openid'
          - 'profile'
          - 'email'
          - 'groups'
        userinfo_signed_response_alg: 'none'
        token_endpoint_auth_method: 'client_secret_basic'

Application

Installation

The plugin required to use OpenID Connect 1.0 can either be installed and configured via the GUI or via Jenkins Configuration as Code.

Via the UI

To install the Jenkins plugin for OpenID Connect 1.0 via the UI:

  1. Visit Manage Jenkins.

  2. Visit Plugins.

  3. Visit Available Plugins.

  4. Search for oic-auth.

  5. Install.

  6. Restart Jenkins.

  7. Proceed to the Configuration step.

Via Jenkins Configuration as Code

Ensure the plugin is installed before running the Jenkins Configuration as Code:

jenkins-plugin-cli --plugins oic-auth

Add this to your Jenkins Configuration as Code:

jenkins:
  systemMessage: "This Jenkins instance was configured using the Authelia example Configuration as Code, thanks Authelia!"
  securityRealm:
    oic:
      automanualconfigure: auto
      wellKnownOpenIDConfigurationUrl: https://auth.example.com/.well-known/openid-configuration
      clientId: jenkins
      clientSecret: insecure_secret
      tokenAuthMethod: client_secret_basic
      scopes: openid profile email groups
      userNameField: preferred_username
      groupsFieldName: groups
      fullNameFieldName: name
      emailFieldName: email
      pkceEnabled: true
      # escapeHatchEnabled: <boolean>
      # escapeHatchUsername: escapeHatchUsername
      # escapeHatchSecret: <string:secret>
      # escapeHatchGroup: <string>

Configuration

To configure Jenkins to utilize Authelia as an OpenID Connect 1.0 Provider:

  1. Visit Manage Jenkins.
  2. Visit Security.
  3. Select Login with Openid Connect in the Security Realm.
  4. Enter jenkins in the Client id field.
  5. Enter insecure_secret in the Client secret field.
  6. Select Automatic configuration from the configuration mode.
  7. Enter https://auth.example.com/.well-known/openid-configuration in the Well-known configuration endpoint field.
  8. Select Override scopes.
  9. Enter openid profile email groups in the Scopes field.
  10. Expand Advanced.
  11. Enter preferred_username into the User name field name field.
  12. Enter name into the Full name field name field.
  13. Enter email into the Email field name field.
  14. Enter groups into the Groups field name field.
  15. Select Enable Proof Key for Code Exchange.
  16. Consider using the Configure 'escape hatch' for when the OpenID Provider is unavailable to prevent login issues.

See Also