2020-10-29 11:09:12 -04:00
---
2020-11-27 13:09:52 -05:00
stage: Create
group: Ecosystem
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-10-29 11:09:12 -04:00
---
2014-08-28 04:57:30 -04:00
# Shibboleth OmniAuth Provider
2020-12-04 16:09:29 -05:00
NOTE:
2019-09-17 05:06:11 -04:00
The preferred approach for integrating a Shibboleth authentication system
2020-12-15 22:09:46 -05:00
with GitLab 10 or newer is to use the [GitLab SAML integration ](saml.md ). This documentation is for Omnibus GitLab 9.x installs or older.
2014-08-28 04:57:30 -04:00
2019-09-30 02:06:02 -04:00
In order to enable Shibboleth support in GitLab we need to use Apache instead of NGINX (It may be possible to use NGINX, however this is difficult to configure using the bundled NGINX provided in the Omnibus GitLab package). Apache uses mod_shib2 module for Shibboleth authentication and can pass attributes as headers to OmniAuth Shibboleth provider.
2014-08-28 04:57:30 -04:00
2019-08-27 04:41:50 -04:00
To enable the Shibboleth OmniAuth provider you must configure Apache Shibboleth module.
2019-07-08 19:14:29 -04:00
The installation and configuration of the module itself is out of the scope of this document.
2020-04-07 23:09:31 -04:00
Check < https: / / wiki . shibboleth . net / confluence / display / SP3 / Apache > for more information.
2018-11-20 00:36:07 -05:00
2020-12-11 01:10:17 -05:00
You can find Apache configuration in [GitLab Recipes ](https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache ).
2018-11-20 00:36:07 -05:00
The following changes are needed to enable Shibboleth:
2019-09-30 02:06:02 -04:00
1. Protect OmniAuth Shibboleth callback URL:
2018-11-20 00:36:07 -05:00
2020-02-25 22:09:07 -05:00
```apache
2019-07-11 11:21:26 -04:00
< Location / users / auth / shibboleth / callback >
AuthType shibboleth
ShibRequestSetting requireSession 1
ShibUseHeaders On
require valid-user
< / Location >
Alias /shibboleth-sp /usr/share/shibboleth
< Location / shibboleth-sp >
Satisfy any
< / Location >
< Location / Shibboleth . sso >
SetHandler shib
< / Location >
```
2018-11-20 00:36:07 -05:00
2020-12-11 01:10:17 -05:00
1. Exclude Shibboleth URLs from rewriting. Add `RewriteCond %{REQUEST_URI} !/Shibboleth.sso` and `RewriteCond %{REQUEST_URI} !/shibboleth-sp` . Configuration should look like this:
2018-11-20 00:36:07 -05:00
2020-02-25 22:09:07 -05:00
```apache
2019-07-11 11:21:26 -04:00
# Apache equivalent of Nginx try files
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/Shibboleth.sso
RewriteCond %{REQUEST_URI} !/shibboleth-sp
RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]
RequestHeader set X_FORWARDED_PROTO 'https'
```
2018-11-20 00:36:07 -05:00
2020-12-04 16:09:29 -05:00
NOTE:
2020-02-25 22:09:07 -05:00
Starting from GitLab 11.4, OmniAuth is enabled by default. If you're using an
2020-11-19 13:09:13 -05:00
earlier version, you must explicitly enable it in `/etc/gitlab/gitlab.rb` .
2020-02-25 22:09:07 -05:00
1. In addition, add Shibboleth to `/etc/gitlab/gitlab.rb` as an OmniAuth provider.
2020-11-19 13:09:13 -05:00
User attributes are sent from the
2018-11-20 00:36:07 -05:00
Apache reverse proxy to GitLab as headers with the names from the Shibboleth
attribute mapping. Therefore the values of the `args` hash
should be in the form of `"HTTP_ATTRIBUTE"` . The keys in the hash are arguments
to the [OmniAuth::Strategies::Shibboleth class ](https://github.com/toyokazu/omniauth-shibboleth/blob/master/lib/omniauth/strategies/shibboleth.rb )
2019-08-27 04:41:50 -04:00
and are documented by the [`omniauth-shibboleth` gem ](https://github.com/toyokazu/omniauth-shibboleth )
2018-11-20 00:36:07 -05:00
(take care to note the version of the gem packaged with GitLab). If some of
your users appear to be authenticated by Shibboleth and Apache, but GitLab
rejects their account with a URI that contains "e-mail is invalid" then your
Shibboleth Identity Provider or Attribute Authority may be asserting multiple
e-mail addresses. In this instance, you might consider setting the
`multi_values` argument to `first` .
The file should look like this:
2020-03-25 02:07:58 -04:00
```ruby
2019-07-11 11:21:26 -04:00
external_url 'https://gitlab.example.com'
gitlab_rails['internal_api_url'] = 'https://gitlab.example.com'
# disable Nginx
nginx['enable'] = false
gitlab_rails['omniauth_allow_single_sign_on'] = true
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_providers'] = [
{
"name" => "'shibboleth"',
"label" => "Text for Login Button",
"args" => {
"shib_session_id_field" => "HTTP_SHIB_SESSION_ID",
"shib_application_id_field" => "HTTP_SHIB_APPLICATION_ID",
"uid_field" => 'HTTP_EPPN',
"name_field" => 'HTTP_CN',
"info_fields" => { "email" => 'HTTP_MAIL'}
}
}
]
```
2018-11-20 00:36:07 -05:00
1. [Reconfigure ](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure ) or [restart ](../administration/restart_gitlab.md#installations-from-source ) GitLab for the changes to take effect if you
2017-02-09 02:38:25 -05:00
installed GitLab via Omnibus or from source respectively.
2014-08-28 04:57:30 -04:00
2020-11-19 13:09:13 -05:00
On the sign in page, there should now be a "Sign in with: Shibboleth" icon below the regular sign in form. Click the icon to begin the authentication process. You are redirected to IdP server (depends on your Shibboleth module configuration). If everything goes well the user is returned to GitLab and is signed in.
2016-04-13 21:03:50 -04:00
## Apache 2.4 / GitLab 8.6 update
2018-11-20 00:36:07 -05:00
2016-04-13 21:03:50 -04:00
The order of the first 2 Location directives is important. If they are reversed,
2020-11-19 13:09:13 -05:00
requesting a Shibboleth session fails!
2016-04-13 21:03:50 -04:00
2020-03-25 02:07:58 -04:00
```plaintext
2019-07-11 11:21:26 -04:00
< Location / >
Require all granted
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://YOUR_SERVER_FQDN/
< / Location >
< Location / users / auth / shibboleth / callback >
AuthType shibboleth
ShibRequestSetting requireSession 1
ShibUseHeaders On
Require shib-session
< / Location >
Alias /shibboleth-sp /usr/share/shibboleth
< Location / shibboleth-sp >
Require all granted
< / Location >
< Location / Shibboleth . sso >
SetHandler shib
< / Location >
RewriteEngine on
#Don't escape encoded characters in api requests
RewriteCond %{REQUEST_URI} ^/api/v4/.*
RewriteCond %{REQUEST_URI} !/Shibboleth.sso
RewriteCond %{REQUEST_URI} !/shibboleth-sp
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
#Forward all requests to gitlab-workhorse except existing files
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteCond %{REQUEST_URI} !/Shibboleth.sso
RewriteCond %{REQUEST_URI} !/shibboleth-sp
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
RequestHeader set X_FORWARDED_PROTO 'https'
RequestHeader set X-Forwarded-Ssl on
2017-02-09 02:38:25 -05:00
```