blob: 78140613aebd688005e5a0e5b403604d831e5dfc [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Single Sign-On Security
Shawn O. Pearcef384b442009-01-10 16:20:56 -08002
Shawn O. Pearcee31d02c2009-12-08 12:21:37 -08003Gerrit supports integration with some types of single sign-on
Shawn O. Pearcef384b442009-01-10 16:20:56 -08004security solutions, making it possible for end-users to setup
5and manage accounts, without administrator involvement.
6
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08007== OpenID
Shawn O. Pearcef384b442009-01-10 16:20:56 -08008
9By default a new Gerrit installation relies upon OpenID to perform
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -070010user authentication services. To enable OpenID, the auth.type
11setting should be `OpenID`:
Shawn O. Pearcef384b442009-01-10 16:20:56 -080012
Michael Ochmannb99feab2016-07-06 14:10:22 +020013----
Shawn O. Pearcec5fed822009-11-17 16:10:10 -080014 git config --file $site_path/etc/gerrit.config auth.type OpenID
Michael Ochmannb99feab2016-07-06 14:10:22 +020015----
Shawn O. Pearcef384b442009-01-10 16:20:56 -080016
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -070017As this is the default setting there is nothing required from the
18site administrator to make use of the OpenID authentication services.
Shawn O. Pearcef384b442009-01-10 16:20:56 -080019
20* http://openid.net/[openid.net]
21
Shawn O. Pearceab583db2009-03-03 17:28:04 -080022If Jetty is being used, you may need to increase the header
23buffer size parameter, due to very long header lines.
24Add the following to `$JETTY_HOME/etc/jetty.xml` under
25`org.mortbay.jetty.nio.SelectChannelConnector`:
26
Michael Ochmannb99feab2016-07-06 14:10:22 +020027----
Shawn O. Pearceab583db2009-03-03 17:28:04 -080028 <Set name="headerBufferSize">16384</Set>
Michael Ochmannb99feab2016-07-06 14:10:22 +020029----
Shawn O. Pearceab583db2009-03-03 17:28:04 -080030
Shawn O. Pearcea2299662009-02-25 14:34:40 -080031In order to use permissions beyond those granted to the
32`Anonymous Users` and `Registered Users` groups, an account
33must only have OpenIDs which match at least one pattern from the
Shawn O. Pearced7c026d2009-08-05 20:11:22 -070034`auth.trustedOpenID` list in `gerrit.config`. Patterns may be
Magnus Bäcke5611832011-02-02 08:57:15 +010035either a
36link:http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html[standard
37Java regular expression (java.util.regex)] (must start with `^`
38and end with `$`) or be a simple prefix (any other string).
Shawn O. Pearcea2299662009-02-25 14:34:40 -080039
Shawn O. Pearced7c026d2009-08-05 20:11:22 -070040Out of the box Gerrit is configured to trust two patterns, which
41will match any OpenID provider on the Internet:
Shawn O. Pearcea2299662009-02-25 14:34:40 -080042
43* `http://` -- trust all OpenID providers using the HTTP protocol
44* `https://` -- trust all OpenID providers using the HTTPS protocol
Shawn O. Pearcea2299662009-02-25 14:34:40 -080045
Shawn Pearcea7d3e6c2014-05-23 11:50:06 -070046To trust only Yahoo!:
Michael Ochmannb99feab2016-07-06 14:10:22 +020047----
Shawn Pearcea7d3e6c2014-05-23 11:50:06 -070048 git config --file $site_path/etc/gerrit.config auth.trustedOpenID https://me.yahoo.com
Michael Ochmannb99feab2016-07-06 14:10:22 +020049----
Shawn O. Pearcea2299662009-02-25 14:34:40 -080050
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080051=== Database Schema
Shawn O. Pearcef384b442009-01-10 16:20:56 -080052
53User identities obtained from OpenID providers are stored into the
David Pursehouse8be79ab2014-12-12 15:34:46 +090054`account_external_ids` table.
Shawn O. Pearcef384b442009-01-10 16:20:56 -080055
David Pursehouse8be79ab2014-12-12 15:34:46 +090056=== Multiple Identities
57
58Users may link more than one OpenID identity to the same Gerrit account, making
59it easier for their browser to sign in to Gerrit if they are frequently switching
60between different unique OpenID accounts.
61
62[WARNING]
63Users wishing to link an alternative identity should *NOT* log in separately
64with that identity. Doing so will result in a new account being created, and
65subsequent attempts to link that account with the existing account will fail.
66In cases where this happens, the administrator will need to manually merge the
David Pursehouse78450192018-02-02 10:13:45 +090067accounts. See link:https://gerrit.googlesource.com/homepage/+/md-pages/docs/SqlMergeUserAccounts.md[
David Pursehouse8be79ab2014-12-12 15:34:46 +090068Merging Gerrit User Accounts] on the Gerrit Wiki for details.
69
David Pursehouseca046912014-12-12 15:34:09 +090070Linking another identity is also useful for users whose primary OpenID provider
David Pursehousefb6eba12018-02-02 10:21:17 +090071shuts down. For example Google
David Pursehouseca046912014-12-12 15:34:09 +090072link:https://developers.google.com/+/api/auth-migration[shut down their OpenID
David Pursehousefb6eba12018-02-02 10:21:17 +090073service on 20th April 2015]. Users who failed to add an alternative identity with
74another OpenID provider before that date will end up with their account only having
75a disabled Google identity. After creating a separate account with an alternative
76provider, they will need to ask the administrator to merge the accounts using the
77previously mentioned method.
David Pursehouseca046912014-12-12 15:34:09 +090078
David Pursehouse8be79ab2014-12-12 15:34:46 +090079To link another identity to an existing account:
80
81* Login with the existing account
82* Select menu Settings -> Identities
83* Click the 'Link Another Identity' button
84* Select the OpenID provider for the other identity
85* Authenticate with the other identity
86
87Login using the other identity can only be performed after the linking is
88successful.
Shawn O. Pearcef384b442009-01-10 16:20:56 -080089
Han-Wen Nienhuys84d830b2017-02-15 16:36:04 +010090== HTTP Basic Authentication
Shawn O. Pearcef384b442009-01-10 16:20:56 -080091
92When using HTTP authentication, Gerrit assumes that the servlet
93container or the frontend web server has performed all user
94authentication prior to handing the request off to Gerrit.
95
96As a result of this assumption, Gerrit can assume that any and
97all requests have already been authenticated. The "Sign In" and
98"Sign Out" links are therefore not displayed in the web UI.
99
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700100To enable this form of authentication:
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800101
Michael Ochmannb99feab2016-07-06 14:10:22 +0200102----
Shawn O. Pearcec5fed822009-11-17 16:10:10 -0800103 git config --file $site_path/etc/gerrit.config auth.type HTTP
104 git config --file $site_path/etc/gerrit.config --unset auth.httpHeader
105 git config --file $site_path/etc/gerrit.config auth.emailFormat '{0}@example.com'
Michael Ochmannb99feab2016-07-06 14:10:22 +0200106----
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800107
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700108The auth.type must always be HTTP, indicating the user identity
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800109will be obtained from the HTTP authorization data.
110
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700111The auth.httpHeader must always be unset. If set to any value
112(including `Authorization`) then Gerrit won't correctly honor the
113standard `Authorization` HTTP header.
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800114
Shawn O. Pearce0d3ecff2009-06-01 08:34:17 -0700115The auth.emailFormat field ('optional') sets the preferred email
Edwin Kempincdb0e002011-09-08 14:23:30 +0200116address during first login. Gerrit will replace `{0}` with the
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800117username, as obtained from the Authorization header. A format such
118as shown in the example would be typical, to add the domain name
119of the organization.
120
Shawn O. Pearce818fa752009-08-15 14:44:44 -0700121If Apache HTTPd is being used as the primary web server and the
122Apache server will be handling user authentication, a configuration
123such as the following is recommended to ensure Apache performs the
124authentication at the proper time:
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800125
Michael Ochmannb99feab2016-07-06 14:10:22 +0200126----
Shawn O. Pearce818fa752009-08-15 14:44:44 -0700127 <Location "/login/">
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800128 AuthType Basic
Shawn O. Pearce818fa752009-08-15 14:44:44 -0700129 AuthName "Gerrit Code Review"
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800130 Require valid-user
131 ...
132 </Location>
Michael Ochmannb99feab2016-07-06 14:10:22 +0200133----
Shawn O. Pearce9520f982009-02-06 10:25:11 -0800134
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800135=== Database Schema
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800136
137User identities are stored in the `account_external_ids` table.
138The user string obtained from the authorization header has the prefix
139"gerrit:" and is stored in the `external_id` field. For example,
140if a username was "foo" then the external_id field would be populated
141with "gerrit:foo".
142
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
195User identities are stored in the `account_external_ids` table.
196The user string obtained from Siteminder (e.g. the value in the
197"SM_USER" HTTP header) has the prefix "gerrit:" and is stored in the
198`external_id` field. For example, if a Siteminder username was "foo"
199then the external_id field would be populated with "gerrit:foo".
200
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700201GERRIT
202------
203Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700204
205SEARCHBOX
206---------