blob: 37ab0c089b0e2a22d41dedc7f3d4270c594b525d [file] [log] [blame]
Marian Harbachebeb1542019-12-13 10:42:46 +01001:linkattrs:
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08002= Gerrit Code Review - Single Sign-On Security
Shawn O. Pearcef384b442009-01-10 16:20:56 -08003
Shawn O. Pearcee31d02c2009-12-08 12:21:37 -08004Gerrit supports integration with some types of single sign-on
Shawn O. Pearcef384b442009-01-10 16:20:56 -08005security solutions, making it possible for end-users to setup
6and manage accounts, without administrator involvement.
7
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08008== OpenID
Shawn O. Pearcef384b442009-01-10 16:20:56 -08009
10By default a new Gerrit installation relies upon OpenID to perform
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -070011user authentication services. To enable OpenID, the auth.type
12setting should be `OpenID`:
Shawn O. Pearcef384b442009-01-10 16:20:56 -080013
Michael Ochmannb99feab2016-07-06 14:10:22 +020014----
Shawn O. Pearcec5fed822009-11-17 16:10:10 -080015 git config --file $site_path/etc/gerrit.config auth.type OpenID
Michael Ochmannb99feab2016-07-06 14:10:22 +020016----
Shawn O. Pearcef384b442009-01-10 16:20:56 -080017
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -070018As this is the default setting there is nothing required from the
19site administrator to make use of the OpenID authentication services.
Shawn O. Pearcef384b442009-01-10 16:20:56 -080020
Marian Harbach34253372019-12-10 18:01:31 +010021* http://openid.net/[openid.net,,role=external,window=_blank]
Shawn O. Pearcef384b442009-01-10 16:20:56 -080022
Shawn O. Pearceab583db2009-03-03 17:28:04 -080023If Jetty is being used, you may need to increase the header
24buffer size parameter, due to very long header lines.
25Add the following to `$JETTY_HOME/etc/jetty.xml` under
26`org.mortbay.jetty.nio.SelectChannelConnector`:
27
Michael Ochmannb99feab2016-07-06 14:10:22 +020028----
Shawn O. Pearceab583db2009-03-03 17:28:04 -080029 <Set name="headerBufferSize">16384</Set>
Michael Ochmannb99feab2016-07-06 14:10:22 +020030----
Shawn O. Pearceab583db2009-03-03 17:28:04 -080031
Shawn O. Pearcea2299662009-02-25 14:34:40 -080032In order to use permissions beyond those granted to the
33`Anonymous Users` and `Registered Users` groups, an account
34must only have OpenIDs which match at least one pattern from the
Shawn O. Pearced7c026d2009-08-05 20:11:22 -070035`auth.trustedOpenID` list in `gerrit.config`. Patterns may be
Magnus Bäcke5611832011-02-02 08:57:15 +010036either a
37link:http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html[standard
Marian Harbach34253372019-12-10 18:01:31 +010038Java regular expression (java.util.regex),,role=external,window=_blank] (must start with `^`
Magnus Bäcke5611832011-02-02 08:57:15 +010039and end with `$`) or be a simple prefix (any other string).
Shawn O. Pearcea2299662009-02-25 14:34:40 -080040
Shawn O. Pearced7c026d2009-08-05 20:11:22 -070041Out of the box Gerrit is configured to trust two patterns, which
42will match any OpenID provider on the Internet:
Shawn O. Pearcea2299662009-02-25 14:34:40 -080043
44* `http://` -- trust all OpenID providers using the HTTP protocol
45* `https://` -- trust all OpenID providers using the HTTPS protocol
Shawn O. Pearcea2299662009-02-25 14:34:40 -080046
David Ostrovsky6eef4c42021-04-05 13:12:18 +020047To trust only Launchpad:
Michael Ochmannb99feab2016-07-06 14:10:22 +020048----
David Ostrovsky6eef4c42021-04-05 13:12:18 +020049 git config --file $site_path/etc/gerrit.config auth.trustedOpenID https://login.launchpad.net/+openid
Michael Ochmannb99feab2016-07-06 14:10:22 +020050----
Shawn O. Pearcea2299662009-02-25 14:34:40 -080051
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080052=== Database Schema
Shawn O. Pearcef384b442009-01-10 16:20:56 -080053
Edwin Kempinc3090ee2017-08-23 17:23:49 +020054User identities obtained from OpenID providers are stored as
55link:config-accounts.html#external-ids[external IDs].
Shawn O. Pearcef384b442009-01-10 16:20:56 -080056
David Pursehouse8be79ab2014-12-12 15:34:46 +090057=== Multiple Identities
58
59Users may link more than one OpenID identity to the same Gerrit account, making
60it easier for their browser to sign in to Gerrit if they are frequently switching
61between different unique OpenID accounts.
62
63[WARNING]
64Users wishing to link an alternative identity should *NOT* log in separately
65with that identity. Doing so will result in a new account being created, and
66subsequent attempts to link that account with the existing account will fail.
67In cases where this happens, the administrator will need to manually merge the
David Pursehouse78450192018-02-02 10:13:45 +090068accounts. See link:https://gerrit.googlesource.com/homepage/+/md-pages/docs/SqlMergeUserAccounts.md[
Marian Harbach34253372019-12-10 18:01:31 +010069Merging Gerrit User Accounts,,role=external,window=_blank] on the Gerrit Wiki for details.
David Pursehouse8be79ab2014-12-12 15:34:46 +090070
David Pursehouseca046912014-12-12 15:34:09 +090071Linking another identity is also useful for users whose primary OpenID provider
David Pursehousefb6eba12018-02-02 10:21:17 +090072shuts down. For example Google
David Pursehouseca046912014-12-12 15:34:09 +090073link:https://developers.google.com/+/api/auth-migration[shut down their OpenID
Marian Harbach34253372019-12-10 18:01:31 +010074service on 20th April 2015,,role=external,window=_blank]. Users who failed to add an alternative identity with
David Pursehousefb6eba12018-02-02 10:21:17 +090075another OpenID provider before that date will end up with their account only having
76a disabled Google identity. After creating a separate account with an alternative
77provider, they will need to ask the administrator to merge the accounts using the
78previously mentioned method.
David Pursehouseca046912014-12-12 15:34:09 +090079
David Pursehouse8be79ab2014-12-12 15:34:46 +090080To link another identity to an existing account:
81
82* Login with the existing account
83* Select menu Settings -> Identities
84* Click the 'Link Another Identity' button
85* Select the OpenID provider for the other identity
86* Authenticate with the other identity
87
88Login using the other identity can only be performed after the linking is
89successful.
Shawn O. Pearcef384b442009-01-10 16:20:56 -080090
Han-Wen Nienhuys84d830b2017-02-15 16:36:04 +010091== HTTP Basic Authentication
Shawn O. Pearcef384b442009-01-10 16:20:56 -080092
93When using HTTP authentication, Gerrit assumes that the servlet
94container or the frontend web server has performed all user
95authentication prior to handing the request off to Gerrit.
96
97As a result of this assumption, Gerrit can assume that any and
98all requests have already been authenticated. The "Sign In" and
99"Sign Out" links are therefore not displayed in the web UI.
100
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700101To enable this form of authentication:
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800102
Michael Ochmannb99feab2016-07-06 14:10:22 +0200103----
Shawn O. Pearcec5fed822009-11-17 16:10:10 -0800104 git config --file $site_path/etc/gerrit.config auth.type HTTP
105 git config --file $site_path/etc/gerrit.config --unset auth.httpHeader
106 git config --file $site_path/etc/gerrit.config auth.emailFormat '{0}@example.com'
Michael Ochmannb99feab2016-07-06 14:10:22 +0200107----
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800108
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700109The auth.type must always be HTTP, indicating the user identity
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800110will be obtained from the HTTP authorization data.
111
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700112The auth.httpHeader must always be unset. If set to any value
113(including `Authorization`) then Gerrit won't correctly honor the
114standard `Authorization` HTTP header.
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800115
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700116The auth.emailFormat field ('optional') sets the preferred email
Edwin Kempincdb0e002011-09-08 14:23:30 +0200117address during first login. Gerrit will replace `{0}` with the
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800118username, as obtained from the Authorization header. A format such
119as shown in the example would be typical, to add the domain name
120of the organization.
121
Shawn O. Pearce818fa752009-08-15 14:44:44 -0700122If Apache HTTPd is being used as the primary web server and the
123Apache server will be handling user authentication, a configuration
124such as the following is recommended to ensure Apache performs the
125authentication at the proper time:
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800126
Michael Ochmannb99feab2016-07-06 14:10:22 +0200127----
Shawn O. Pearce818fa752009-08-15 14:44:44 -0700128 <Location "/login/">
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800129 AuthType Basic
Shawn O. Pearce818fa752009-08-15 14:44:44 -0700130 AuthName "Gerrit Code Review"
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800131 Require valid-user
132 ...
133 </Location>
Michael Ochmannb99feab2016-07-06 14:10:22 +0200134----
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800135
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800136=== Database Schema
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800137
Edwin Kempinc3090ee2017-08-23 17:23:49 +0200138User identities are stored as
139link:config-accounts.html#external-ids[external IDs] with "gerrit" as
140scheme. The user string obtained from the authorization header is
141stored as ID of the external ID.
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800142
143
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800144== Computer Associates Siteminder
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800145
146Siteminder is a commercial single sign on solution marketed by
147Computer Associates. It is very common in larger enterprise
148environments.
149
150When using Siteminder, Gerrit assumes it has been installed in a
151servlet container which is running behind an Apache web server,
152and that the Siteminder authentication module has been configured
153within Apache to protect the entire Gerrit application. In this
154configuration all users must authenticate with Siteminder before
155they can access any resource on Gerrit.
156
157As a result of this assumption, Gerrit can assume that any and
158all requests have already been authenticated. The "Sign In" and
159"Sign Out" links are therefore not displayed in the web UI.
160
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700161To enable this form of authentication:
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800162
Michael Ochmannb99feab2016-07-06 14:10:22 +0200163----
Shawn O. Pearcec5fed822009-11-17 16:10:10 -0800164 git config --file $site_path/etc/gerrit.config auth.type HTTP
165 git config --file $site_path/etc/gerrit.config auth.httpHeader SM_USER
166 git config --file $site_path/etc/gerrit.config auth.emailFormat '{0}@example.com'
Michael Ochmannb99feab2016-07-06 14:10:22 +0200167----
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800168
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700169The auth.type must always be HTTP, indicating the user identity
170will be obtained from the HTTP authorization data.
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800171
David Pursehouse221d4f62012-06-08 17:38:08 +0900172The auth.httpHeader indicates in which HTTP header field the Siteminder
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700173product has stored the username. Usually this is "SM_USER", but
174may differ in your environment. Please refer to your organization's
175single sign-on or security group to ensure the setting is correct.
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800176
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700177The auth.emailFormat field ('optional') sets the user's preferred
Edwin Kempincdb0e002011-09-08 14:23:30 +0200178email address when they first login. Gerrit will replace `{0}`
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700179with the username, as supplied by Siteminder. A format such as
180shown in the example would be typical, to add the domain name of
181the organization.
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800182
Shawn O. Pearceab583db2009-03-03 17:28:04 -0800183If Jetty is being used, you may need to increase the header
184buffer size parameter, due to very long header lines.
185Add the following to `$JETTY_HOME/etc/jetty.xml` under
186`org.mortbay.jetty.nio.SelectChannelConnector`:
Shawn O. Pearce4246f382009-02-20 18:38:14 -0800187
Michael Ochmannb99feab2016-07-06 14:10:22 +0200188----
Shawn O. Pearce4246f382009-02-20 18:38:14 -0800189 <Set name="headerBufferSize">16384</Set>
Michael Ochmannb99feab2016-07-06 14:10:22 +0200190----
Shawn O. Pearce4246f382009-02-20 18:38:14 -0800191
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800192
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800193=== Database Schema
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800194
Edwin Kempinc3090ee2017-08-23 17:23:49 +0200195User identities are stored as
196link:config-accounts.html#external-ids[external IDs] with "gerrit" as
197scheme. The user string obtained from Siteminder (e.g. the value in the
198"SM_USER" HTTP header) is stored as ID in the external ID.
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800199
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700200GERRIT
201------
202Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700203
204SEARCHBOX
205---------