Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Single Sign-On Security |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 2 | |
Shawn O. Pearce | e31d02c | 2009-12-08 12:21:37 -0800 | [diff] [blame] | 3 | Gerrit supports integration with some types of single sign-on |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 4 | security solutions, making it possible for end-users to setup |
| 5 | and manage accounts, without administrator involvement. |
| 6 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 7 | == OpenID |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 8 | |
| 9 | By default a new Gerrit installation relies upon OpenID to perform |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 10 | user authentication services. To enable OpenID, the auth.type |
| 11 | setting should be `OpenID`: |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 12 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 13 | ---- |
Shawn O. Pearce | c5fed82 | 2009-11-17 16:10:10 -0800 | [diff] [blame] | 14 | git config --file $site_path/etc/gerrit.config auth.type OpenID |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 15 | ---- |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 16 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 17 | As this is the default setting there is nothing required from the |
| 18 | site administrator to make use of the OpenID authentication services. |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 19 | |
| 20 | * http://openid.net/[openid.net] |
| 21 | |
Shawn O. Pearce | ab583db | 2009-03-03 17:28:04 -0800 | [diff] [blame] | 22 | If Jetty is being used, you may need to increase the header |
| 23 | buffer size parameter, due to very long header lines. |
| 24 | Add the following to `$JETTY_HOME/etc/jetty.xml` under |
| 25 | `org.mortbay.jetty.nio.SelectChannelConnector`: |
| 26 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 27 | ---- |
Shawn O. Pearce | ab583db | 2009-03-03 17:28:04 -0800 | [diff] [blame] | 28 | <Set name="headerBufferSize">16384</Set> |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 29 | ---- |
Shawn O. Pearce | ab583db | 2009-03-03 17:28:04 -0800 | [diff] [blame] | 30 | |
Shawn O. Pearce | a229966 | 2009-02-25 14:34:40 -0800 | [diff] [blame] | 31 | In order to use permissions beyond those granted to the |
| 32 | `Anonymous Users` and `Registered Users` groups, an account |
| 33 | must only have OpenIDs which match at least one pattern from the |
Shawn O. Pearce | d7c026d | 2009-08-05 20:11:22 -0700 | [diff] [blame] | 34 | `auth.trustedOpenID` list in `gerrit.config`. Patterns may be |
Magnus Bäck | e561183 | 2011-02-02 08:57:15 +0100 | [diff] [blame] | 35 | either a |
| 36 | link:http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html[standard |
| 37 | Java regular expression (java.util.regex)] (must start with `^` |
| 38 | and end with `$`) or be a simple prefix (any other string). |
Shawn O. Pearce | a229966 | 2009-02-25 14:34:40 -0800 | [diff] [blame] | 39 | |
Shawn O. Pearce | d7c026d | 2009-08-05 20:11:22 -0700 | [diff] [blame] | 40 | Out of the box Gerrit is configured to trust two patterns, which |
| 41 | will match any OpenID provider on the Internet: |
Shawn O. Pearce | a229966 | 2009-02-25 14:34:40 -0800 | [diff] [blame] | 42 | |
| 43 | * `http://` -- trust all OpenID providers using the HTTP protocol |
| 44 | * `https://` -- trust all OpenID providers using the HTTPS protocol |
Shawn O. Pearce | a229966 | 2009-02-25 14:34:40 -0800 | [diff] [blame] | 45 | |
Shawn Pearce | a7d3e6c | 2014-05-23 11:50:06 -0700 | [diff] [blame] | 46 | To trust only Yahoo!: |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 47 | ---- |
Shawn Pearce | a7d3e6c | 2014-05-23 11:50:06 -0700 | [diff] [blame] | 48 | git config --file $site_path/etc/gerrit.config auth.trustedOpenID https://me.yahoo.com |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 49 | ---- |
Shawn O. Pearce | a229966 | 2009-02-25 14:34:40 -0800 | [diff] [blame] | 50 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 51 | === Database Schema |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 52 | |
| 53 | User identities obtained from OpenID providers are stored into the |
David Pursehouse | 8be79ab | 2014-12-12 15:34:46 +0900 | [diff] [blame] | 54 | `account_external_ids` table. |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 55 | |
David Pursehouse | 8be79ab | 2014-12-12 15:34:46 +0900 | [diff] [blame] | 56 | === Multiple Identities |
| 57 | |
| 58 | Users may link more than one OpenID identity to the same Gerrit account, making |
| 59 | it easier for their browser to sign in to Gerrit if they are frequently switching |
| 60 | between different unique OpenID accounts. |
| 61 | |
| 62 | [WARNING] |
| 63 | Users wishing to link an alternative identity should *NOT* log in separately |
| 64 | with that identity. Doing so will result in a new account being created, and |
| 65 | subsequent attempts to link that account with the existing account will fail. |
| 66 | In cases where this happens, the administrator will need to manually merge the |
| 67 | accounts. See link:https://code.google.com/p/gerrit/wiki/SqlMergeUserAccounts[ |
| 68 | Merging Gerrit User Accounts] on the Gerrit Wiki for details. |
| 69 | |
David Pursehouse | ca04691 | 2014-12-12 15:34:09 +0900 | [diff] [blame] | 70 | Linking another identity is also useful for users whose primary OpenID provider |
| 71 | shuts down. For example Google will |
| 72 | link:https://developers.google.com/+/api/auth-migration[shut down their OpenID |
| 73 | service on 20th April 2015]. Users must add an alternative identity, using another |
| 74 | OpenID provider, before that shutdown date. User who fail to add an alternative |
| 75 | identity before that date, and end up with their account only having a disabled |
| 76 | Google identity, will need to create a separate account with an alternative |
| 77 | provider and then ask the administrator to merge the accounts using the previously |
| 78 | mentioned method. |
| 79 | |
David Pursehouse | 8be79ab | 2014-12-12 15:34:46 +0900 | [diff] [blame] | 80 | To 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 | |
| 88 | Login using the other identity can only be performed after the linking is |
| 89 | successful. |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 90 | |
Han-Wen Nienhuys | 84d830b | 2017-02-15 16:36:04 +0100 | [diff] [blame] | 91 | == HTTP Basic Authentication |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 92 | |
| 93 | When using HTTP authentication, Gerrit assumes that the servlet |
| 94 | container or the frontend web server has performed all user |
| 95 | authentication prior to handing the request off to Gerrit. |
| 96 | |
| 97 | As a result of this assumption, Gerrit can assume that any and |
| 98 | all requests have already been authenticated. The "Sign In" and |
| 99 | "Sign Out" links are therefore not displayed in the web UI. |
| 100 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 101 | To enable this form of authentication: |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 102 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 103 | ---- |
Shawn O. Pearce | c5fed82 | 2009-11-17 16:10:10 -0800 | [diff] [blame] | 104 | 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 Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 107 | ---- |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 108 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 109 | The auth.type must always be HTTP, indicating the user identity |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 110 | will be obtained from the HTTP authorization data. |
| 111 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 112 | The auth.httpHeader must always be unset. If set to any value |
| 113 | (including `Authorization`) then Gerrit won't correctly honor the |
| 114 | standard `Authorization` HTTP header. |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 115 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 116 | The auth.emailFormat field ('optional') sets the preferred email |
Edwin Kempin | cdb0e00 | 2011-09-08 14:23:30 +0200 | [diff] [blame] | 117 | address during first login. Gerrit will replace `{0}` with the |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 118 | username, as obtained from the Authorization header. A format such |
| 119 | as shown in the example would be typical, to add the domain name |
| 120 | of the organization. |
| 121 | |
Shawn O. Pearce | 818fa75 | 2009-08-15 14:44:44 -0700 | [diff] [blame] | 122 | If Apache HTTPd is being used as the primary web server and the |
| 123 | Apache server will be handling user authentication, a configuration |
| 124 | such as the following is recommended to ensure Apache performs the |
| 125 | authentication at the proper time: |
Shawn O. Pearce | 9520f98 | 2009-02-06 10:25:11 -0800 | [diff] [blame] | 126 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 127 | ---- |
Shawn O. Pearce | 818fa75 | 2009-08-15 14:44:44 -0700 | [diff] [blame] | 128 | <Location "/login/"> |
Shawn O. Pearce | 9520f98 | 2009-02-06 10:25:11 -0800 | [diff] [blame] | 129 | AuthType Basic |
Shawn O. Pearce | 818fa75 | 2009-08-15 14:44:44 -0700 | [diff] [blame] | 130 | AuthName "Gerrit Code Review" |
Shawn O. Pearce | 9520f98 | 2009-02-06 10:25:11 -0800 | [diff] [blame] | 131 | Require valid-user |
| 132 | ... |
| 133 | </Location> |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 134 | ---- |
Shawn O. Pearce | 9520f98 | 2009-02-06 10:25:11 -0800 | [diff] [blame] | 135 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 136 | === Database Schema |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 137 | |
| 138 | User identities are stored in the `account_external_ids` table. |
| 139 | The user string obtained from the authorization header has the prefix |
| 140 | "gerrit:" and is stored in the `external_id` field. For example, |
| 141 | if a username was "foo" then the external_id field would be populated |
| 142 | with "gerrit:foo". |
| 143 | |
| 144 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 145 | == Computer Associates Siteminder |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 146 | |
| 147 | Siteminder is a commercial single sign on solution marketed by |
| 148 | Computer Associates. It is very common in larger enterprise |
| 149 | environments. |
| 150 | |
| 151 | When using Siteminder, Gerrit assumes it has been installed in a |
| 152 | servlet container which is running behind an Apache web server, |
| 153 | and that the Siteminder authentication module has been configured |
| 154 | within Apache to protect the entire Gerrit application. In this |
| 155 | configuration all users must authenticate with Siteminder before |
| 156 | they can access any resource on Gerrit. |
| 157 | |
| 158 | As a result of this assumption, Gerrit can assume that any and |
| 159 | all requests have already been authenticated. The "Sign In" and |
| 160 | "Sign Out" links are therefore not displayed in the web UI. |
| 161 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 162 | To enable this form of authentication: |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 163 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 164 | ---- |
Shawn O. Pearce | c5fed82 | 2009-11-17 16:10:10 -0800 | [diff] [blame] | 165 | git config --file $site_path/etc/gerrit.config auth.type HTTP |
| 166 | git config --file $site_path/etc/gerrit.config auth.httpHeader SM_USER |
| 167 | git config --file $site_path/etc/gerrit.config auth.emailFormat '{0}@example.com' |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 168 | ---- |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 169 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 170 | The auth.type must always be HTTP, indicating the user identity |
| 171 | will be obtained from the HTTP authorization data. |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 172 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 173 | The auth.httpHeader indicates in which HTTP header field the Siteminder |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 174 | product has stored the username. Usually this is "SM_USER", but |
| 175 | may differ in your environment. Please refer to your organization's |
| 176 | single sign-on or security group to ensure the setting is correct. |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 177 | |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 178 | The auth.emailFormat field ('optional') sets the user's preferred |
Edwin Kempin | cdb0e00 | 2011-09-08 14:23:30 +0200 | [diff] [blame] | 179 | email address when they first login. Gerrit will replace `{0}` |
Shawn O. Pearce | 0d3ecff | 2009-06-01 08:34:17 -0700 | [diff] [blame] | 180 | with the username, as supplied by Siteminder. A format such as |
| 181 | shown in the example would be typical, to add the domain name of |
| 182 | the organization. |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 183 | |
Shawn O. Pearce | ab583db | 2009-03-03 17:28:04 -0800 | [diff] [blame] | 184 | If Jetty is being used, you may need to increase the header |
| 185 | buffer size parameter, due to very long header lines. |
| 186 | Add the following to `$JETTY_HOME/etc/jetty.xml` under |
| 187 | `org.mortbay.jetty.nio.SelectChannelConnector`: |
Shawn O. Pearce | 4246f38 | 2009-02-20 18:38:14 -0800 | [diff] [blame] | 188 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 189 | ---- |
Shawn O. Pearce | 4246f38 | 2009-02-20 18:38:14 -0800 | [diff] [blame] | 190 | <Set name="headerBufferSize">16384</Set> |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 191 | ---- |
Shawn O. Pearce | 4246f38 | 2009-02-20 18:38:14 -0800 | [diff] [blame] | 192 | |
Shawn O. Pearce | 9520f98 | 2009-02-06 10:25:11 -0800 | [diff] [blame] | 193 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 194 | === Database Schema |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 195 | |
| 196 | User identities are stored in the `account_external_ids` table. |
| 197 | The user string obtained from Siteminder (e.g. the value in the |
| 198 | "SM_USER" HTTP header) has the prefix "gerrit:" and is stored in the |
| 199 | `external_id` field. For example, if a Siteminder username was "foo" |
| 200 | then the external_id field would be populated with "gerrit:foo". |
| 201 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 202 | GERRIT |
| 203 | ------ |
| 204 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 205 | |
| 206 | SEARCHBOX |
| 207 | --------- |