jenkinsci / cas-plugin

Jenkins CAS Plugin
https://plugins.jenkins.io/cas-plugin/
MIT License
9 stars 15 forks source link
cas jenkins-plugin security user

Jenkins Plugin Jenkins Plugin installs Build Status

Jenkins CAS Plugin

This is a Jenkins plugin providing authentication with CAS, with Single Sign-On (SSO) and Single Logout (SLO) support.

Installation

The latest version is available for download from the Update Center and from the Download Site.

Upgrade notice

In these cases, you will need to upgrade Jenkins and CAS plugin together to avoid issues. This means manually downloading and updating the cas-plugin.hpi file in your Jenkins plugins directory (rename to cas-plugin.jpi as needed).

Building from source

  1. Checkout or download the source code from the current master or latest tag on GitHub.
  2. Execute mvn clean verify from your local source code folder (install Maven if not already done).
  3. Find the cas-plugin.hpi file in the target subfolder.
  4. Upload it to Jenkins from the Advanced tab of the Manage Plugins page.

Setup

Basic Setup

  1. Install the plugin from Manage Jenkins > Manage Plugins > Available > CAS Plugin.
  2. Go to Manage Jenkins > Configure Global Security, check Enable Security and select CAS (Central Authentication Service) as the Security Realm.
  3. Next to CAS Server URL, enter the base URL to your CAS server, e.g. https://cas.example.com/cas
  4. Next to CAS Protocol, select the protocol to use to communicate with CAS, e.g. SAML 1.1 if you are using Apereo CAS Server 3.x or higher, or CAS 3.0 if you are using Apereo CAS Server 4.x or higher.
  5. If there are no warnings, click the Save button at the bottom and attempt logging in.

Advanced Setup

Additional configuration options are available under the Security Realm section:

Several protocols implemented by CAS are available in the CAS Protocol dropdown (click the Advanced... button to reveal more options):

Attributes are an easy (and recommended) way to add full name and email address information to an authenticated user, as well as roles/groups membership. CAS 1.0 response parsing with a custom Groovy script is made available as a legacy option for backward compatibility with the CAS1 Plugin.

Usage

Access from external/scripted clients

By default, when using the CAS plugin for authentication, you cannot use a regular username/password for remote authentication into Jenkins. This is by design, as the CAS protocol does not allow "direct" authentication and works with secure redirections, which are not compatible with remote calls such as SVN or GitHub hooks.

You have two options:

See the following page for more information: Authenticating scripted clients

Jenkins URL when used behind a reverse proxy

When using Jenkins behind a reverse proxy, depending on configuration the URL users get redirected to after authentication may be wrong. If this is the case:

  1. Go to Manage Jenkins > Configure System.
  2. Under Jenkins Location, make sure the Jenkins URL is valid and can be reached by users. It will be used by CAS to redirect back to Jenkins after authentication.

Troubleshooting

SSL certificate issues

Please see the Troubleshooting Guide from the CAS Project.

Issue validating SAML 1.1 tickets

If Jenkins systematically fails to validate SAML 1.1 tickets, make sure to check whether the system clock of your Jenkins and CAS servers are synchronized. Indeed, the timestamp at which SAML 1.1 tickets were generated is checked when validating them, with a configurable tolerance (see "Time Tolerance" plugin option). Out-of-sync clocks may log errors such as "skipping assertion that's not yet valid" in Jenkins.

Failure to authenticate external/scripted clients

By default, using normal username/password is not possible from external/scripted clients when using CAS. You may use an API token instead and/or enable the REST API support. See "Usage" section above for more details.

Missing group memberships when logging with external/scripted clients

This issue (JENKINS-20064) is fixed in Jenkins 1.556 and higher, provided that the user logged in through the web interface at least once. This limitation does not apply when the REST API option is enabled along with the real username/password.

Invalid Jenkins URL after logging in through CAS

If Jenkins is behind a reverse proxy, it may not be able to detect its own URL by itself. In this case, you need to manually configure the Jenkins URL. See "Usage" section above for a solution.

Documentation