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