Merge branch '6264-cwl-runner' closes #6264
[arvados.git] / doc / install / install-sso.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install Single Sign On (SSO) server
5 ...
6
7 h2(#dependencies). Install dependencies
8
9 Make sure you have "Ruby and Bundler":install-manual-prerequisites-ruby.html installed.
10
11 On a Debian-based system, install the following packages:
12
13 <notextile>
14 <pre><code>~$ <span class="userinput">sudo apt-get install git libpq-dev postgresql</span>
15 </code></pre>
16 </notextile>
17
18 On a Red Hat-based system, install the following packages:
19
20 <notextile>
21 <pre><code>~$ <span class="userinput">sudo yum install git postgresql postgresql-devel</span>
22 </code></pre>
23 </notextile>
24
25 {% include 'notebox_begin' %}
26 If your distribution offers PostgreSQL 8, consider using Software Collections to install postgresql92 and postgresql92-postgresql-devel instead, as described on the "API server installation page":install-api-server.html.
27 {% include 'notebox_end' %}
28
29 h2(#install). Install SSO server
30
31 h3. Get SSO server code and run bundle
32
33 <notextile>
34 <pre><code>~$ <span class="userinput">cd $HOME</span> # (or wherever you want to install)
35 ~$ <span class="userinput">git clone https://github.com/curoverse/sso-devise-omniauth-provider.git</span>
36 ~$ <span class="userinput">cd sso-devise-omniauth-provider</span>
37 ~/sso-devise-omniauth-provider$ <span class="userinput">bundle</span>
38 </code></pre></notextile>
39
40 h2. Configure the SSO server
41
42 First, copy the example configuration file:
43
44 <notextile>
45 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">cp -i config/application.yml.example config/application.yml</span>
46 </code></pre></notextile>
47
48 The SSO server reads the @config/application.yml@ file, as well as the @config/application.defaults.yml@ file. Values in @config/application.yml@ take precedence over the defaults that are defined in @config/application.defaults.yml@. The @config/application.yml.example@ file is not read by the SSO server and is provided for installation convenience, only.
49
50 Consult @config/application.default.yml@ for a full list of configuration options. Always put your local configuration in @config/application.yml@, never edit @config/application.default.yml@.
51
52 h3(#uuid_prefix). uuid_prefix
53
54 Define your @uuid_prefix@ in @config/application.yml@ by setting the @uuid_prefix@ field in the section for your environment.  This prefix is used for all database identifiers to identify the record as originating from this site.  It must be exactly 5 alphanumeric characters (lowercase ASCII letters and digits).
55
56 h3(#secret_token). secret_token
57
58 Generate a new secret token for signing cookies:
59
60 <notextile>
61 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">ruby -e 'puts rand(2**400).to_s(36)'</span>
62 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
63 </code></pre></notextile>
64
65 Then put that value in the @secret_token@ field.
66
67 h3(#authentication_methods). Authentication methods
68
69 Three authentication methods are supported: Google+, LDAP, and local accounts.
70
71 h3(#google). Google+ authentication
72
73 In order to use Google+ authentication, you must use the "Google Developers Console":https://console.developers.google.com to create a set of client credentials. In short:
74
75 * Enable the Contacts and Google+ APIs.
76 * Create an OAuth Client ID for a web application.
77 ** JavaScript origins: @https://sso.example.com/@
78 ** Redirect URIs: @https://sso.example.com/auth/google_oauth2/callback@
79
80 Copy the "Client ID" and "Client secret" values from the Google Developers Console into the Google section of @config/application.yml@, like this:
81
82 <notextile>
83 <pre><code>
84   # Google API tokens required for OAuth2 login.
85   #
86   # See https://github.com/zquestz/omniauth-google-oauth2
87   #
88   # and https://developers.google.com/accounts/docs/OAuth2
89   google_oauth2_client_id: "<span class="userinput">---YOUR---CLIENT---ID---HERE---</span>"
90   google_oauth2_client_secret: "<span class="userinput">---YOUR---CLIENT---SECRET---HERE---</span>"
91
92   # Set this to your OpenId 2.0 realm to enable migration from Google OpenId
93   # 2.0 to Google OAuth2 OpenId Connect (Google will provide OpenId 2.0 user
94   # identifiers via the openid.realm parameter in the OAuth2 flow until 2017).
95   google_openid_realm: <span class="userinput">false</span></code></pre></notextile>
96
97 h3(#ldap). LDAP authentication
98
99 LDAP authentication can be configured with these options. Make sure to preserve the indentation of the fields beyond @use_ldap@.
100
101 <pre>
102   # Enable LDAP support.
103   #
104   # If you want to use LDAP, you need to provide
105   # the following set of fields under the use_ldap key.
106   #
107   # use_ldap: false
108   #   title: Example LDAP
109   #   host: ldap.example.com
110   #   port: 636
111   #   method: ssl
112   #   base: "ou=Users, dc=example, dc=com"
113   #   uid: uid
114   #   email_domain: example.com
115   #   #bind_dn: "some_user"
116   #   #password: "some_password"
117   use_ldap: false
118 </pre>
119
120 h3(#local_accounts). Local account authentication
121
122 If neither Google OAuth2 nor LDAP are enabled, the SSO server automatically
123 falls back to local accounts. There are two configuration options for local
124 accounts:
125
126 <pre>
127   # If true, allow new creation of new accounts in the SSO server's internal
128   # user database.
129   allow_account_registration: false
130
131   # If true, send an email confirmation before activating new accounts in the
132   # SSO server's internal user database.
133   require_email_confirmation: false
134 </pre>
135
136 You can also create local accounts on the SSO server from the rails console:
137
138 <notextile>
139 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">RAILS_ENV=production bundle exec rails console</span>
140 :001 &gt; <span class="userinput">user = User.new(:email =&gt; "test@example.com")</span>
141 :002 &gt; <span class="userinput">user.password = "passw0rd"</span>
142 :003 &gt; <span class="userinput">user.save!</span>
143 :004 &gt; <span class="userinput">quit</span>
144 </code></pre>
145 </notextile>
146
147 h2. Set up the database
148
149 Generate a new database password. Nobody ever needs to memorize it or type it, so make a strong one:
150
151 <notextile>
152 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">ruby -e 'puts rand(2**128).to_s(36)'</span>
153 abcdefghijklmnopqrstuvwxyz012345689
154 </code></pre></notextile>
155
156 Create a new database user with permission to create its own databases.
157
158 <notextile>
159 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">sudo -u postgres createuser --createdb --encrypted -R -S --pwprompt arvados_sso</span>
160 Enter password for new role: <span class="userinput">paste-database-password-you-generated</span>
161 Enter it again: <span class="userinput">paste-database-password-you-generated</span>
162 </code></pre></notextile>
163
164 Configure SSO server to connect to your database by creating and updating @config/database.yml@. Replace the @xxxxxxxx@ database password placeholders with the new password you generated above.
165
166 <notextile>
167 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">cp -i config/database.yml.sample config/database.yml</span>
168 ~/sso-devise-omniauth-provider$ <span class="userinput">edit config/database.yml</span>
169 </code></pre></notextile>
170
171 Create and initialize the database. If you are planning a production system, choose the @production@ rails environment, otherwise use @development@.
172
173 <notextile>
174 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">RAILS_ENV=production bundle exec rake db:setup</span>
175 </code></pre></notextile>
176
177 Alternatively, if the database user you intend to use for the SSO server is not allowed to create new databases, you can create the database first and then populate it with rake. Be sure to adjust the database name if you are using the @development@ environment. This sequence of commands is functionally equivalent to the rake db:setup command above:
178
179 <notextile>
180 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">su postgres createdb arvados_sso_production -E UTF8 -O arvados_sso</span>
181 ~/sso-devise-omniauth-provider$ <span class="userinput">RAILS_ENV=production bundle exec rake db:schema:load</span>
182 ~/sso-devise-omniauth-provider$ <span class="userinput">RAILS_ENV=production bundle exec rake db:seed</span>
183 </code></pre></notextile>
184
185 h2(#client). Generate assets
186
187 If you are running in the production environment, you'll want to generate the assets:
188
189 <notextile>
190 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">RAILS_ENV=production bundle exec rake assets:precompile</span>
191 </code></pre>
192 </notextile>
193
194 h2(#client). Create arvados-server client
195
196 Use @rails console@ to create a @Client@ record that will be used by the Arvados API server.  The values of @app_id@ and @app_secret@ correspond to the @APP_ID@ and @APP_SECRET@ that must be set in in "Setting up Omniauth in the API server.":install-api-server.html#omniauth
197
198 <notextile>
199 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">ruby -e 'puts rand(2**400).to_s(36)'</span>
200 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
201 ~/sso-devise-omniauth-provider$ <span class="userinput">RAILS_ENV=production bundle exec rails console</span>
202 :001 &gt; <span class="userinput">c = Client.new</span>
203 :002 &gt; <span class="userinput">c.name = "joshid"</span>
204 :003 &gt; <span class="userinput">c.app_id = "arvados-server"</span>
205 :004 &gt; <span class="userinput">c.app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"</span>
206 :005 &gt; <span class="userinput">c.save!</span>
207 :006 &gt; <span class="userinput">quit</span>
208 </code></pre>
209 </notextile>
210
211 h2. Start the SSO server
212
213 h3. Run a simple standalone server
214
215 You can use the Webrick server that is bundled with Ruby to quickly verify that your installation is functioning:
216
217 <notextile>
218 <pre><code>~/sso-devise-omniauth-provider$ <span class="userinput">RAILS_ENV=production bundle exec rails server</span>
219 </code></pre>
220 </notextile>
221
222 h3. Production environment
223
224 As a Ruby on Rails application, the SSO server should be compatible with any Ruby application server that supports Rack applications.  We recommend "Passenger":https://www.phusionpassenger.com/ to run the SSO server in production.