In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

This Server has been upgraded to GitLab release 14.2.6

DOC 17.8 KB
Newer Older
haemmer's avatar
haemmer committed
1
Copyright (c) 2013, SWITCH - Serving Swiss Universities
2
3
4
See LICENSE file for details.

-------------------------------------------------------------------------------
haemmer's avatar
haemmer committed
5
6
7
8
9
10
11
12
13
14

SWITCHwayf Documentation
========================

Find below the documentation and configuration options for the SWITCHwayf.

-------------------------------------------------------------------------------

**This document is written in the markdown syntax**

15
16
-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
17
18
Description
-----------
19
20
21
The SWITCHwayf is an implementation of the Shibboleth WAYF and SAML2 Discovery 
Service protocol for use withing a Shibboleth architecture.

haemmer's avatar
haemmer committed
22
Some of the Features:
haemmer's avatar
haemmer committed
23

haemmer's avatar
haemmer committed
24
25
26
27
28
29
30
31
32
33
- Supports Discovery Service and the Shibboleth authentication request protocol 
- Supports processing SAML2 metadata files
- Search-as-you type or selection from a list of organisations
- Various customizations options for header, footer, language strings etc.
- I18N support, currently language packs for en, de, it, fr and some other 
  languages are included
- HTML code generation for embedding the WAYF directly into a web page
- Support for remembering IdP selection accross different services (when 
  Embedded WAYF is used)
- Preselecting entry in drop down list by
34
35
  - SAML common domain cookie that contains selected Identity Providers 
  - resource path info hint (e.g. 
haemmer's avatar
haemmer committed
36
37
    /WAYF/unige.ch?shire=https://... selects University  of Geneva, depends 
    of course on the ID scheme a federation uses)
38
39
40
  - Kerberos preselection
  - IP range preselection
  - IP reverse DNS lookup preselection
haemmer's avatar
haemmer committed
41
- Transparent redirection mode, e.g. /WAYF/unige.ch/redirect?shire=https://...
42
43
44

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
45
46
Customization Options
---------------------
haemmer's avatar
haemmer committed
47
48
Since version 1.12 any graphical aspects can be customized such that these 
changes normally should survive bug-fix and minor version upgrades. 
49
50
51
52
53
Files whose names start with 'default-' can be copied and renamed to start with 
'custom-' in order to  customize the file's behaviour.

In particular, the following customizations can be applied:

haemmer's avatar
haemmer committed
54
* HTML Header:   custom-header.php  
haemmer's avatar
haemmer committed
55
  Customize page header
56

haemmer's avatar
haemmer committed
57
* HTML Footer:   custom-footer.php  
58
59
Customize page footer 

haemmer's avatar
haemmer committed
60
* HTML Body:     custom-body.php  
haemmer's avatar
haemmer committed
61
  Customize WAYF/DS body
62

haemmer's avatar
haemmer committed
63
* HTML Body:     custom-settings.php  
haemmer's avatar
haemmer committed
64
  Customize WAYF/DS permanent settings body
65

haemmer's avatar
haemmer committed
66
* HTML Body:     custom-notice.php  
haemmer's avatar
haemmer committed
67
  Customize WAYF/DS permanent settings notice body
68

haemmer's avatar
haemmer committed
69
* HTML Body:     custom-embedded-wayf.php  
haemmer's avatar
haemmer committed
70
  Customize WAYF/DS body
71

haemmer's avatar
haemmer committed
72
* HTML Error:    custom-error.php  
haemmer's avatar
haemmer committed
73
  Customize error messages
74

haemmer's avatar
haemmer committed
75
76
77
78
79
80
81
82
* CSS Main Style:    css/custom-styles.css
  Customize CSS styles that are loaded in addition to the default-styles.css.
  Therefore, they can be used to overwrite the default CSS styles.

* CSS Improved Drop Down Style:    css/custom-ImprovedDropDown.css
  Customize CSS styles to alter the appearance of the improved drop-down list,
  both for the stand-alone WAYF as well as the Embedded WAYF. The styles are
  loaded in addition to the default-ImprovedDropDown.css.
83

haemmer's avatar
haemmer committed
84
* Languages:     custom-languages.php  
haemmer's avatar
haemmer committed
85
86
87
88
  Can be used to change default or add new language strings. The custom 
  languages strings in addition to the default styles. Therefore, they can be 
  used to overwrite the default CSS styles.

haemmer's avatar
haemmer committed
89
90
If a custom file doesn't exist yet, the default templates and settings 
are used. To create a custom template, copy the default files with:
haemmer's avatar
haemmer committed
91

haemmer's avatar
haemmer committed
92
`cp default-{$template}.php custom-{$template}.php`
93

haemmer's avatar
haemmer committed
94
95
96
where {$template} stands for the file you want to customize. Unless otherwise 
mentioned the custom files replace the default files completely. Please read the
above information for each custom file.
97
98
99

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
100
101
102
Logging
-------

103
104
105
106
107
108
109
Errors are generally written to syslog. Error messages might be cases where
files cannot be read or written due to permission problems.

If the configuration option $useLogging is true, a log file will be written to 
the path specified in $WAYFLogFile. This log file is an audit log file where 
each line is an entry of the form:

haemmer's avatar
haemmer committed
110
{DATE} {TIME} {IP} {IDP-SELECTION} {REQUEST-TYPE} {IDP-ENTITYID} {FORWARDING-URL}
111
112
113

Log entries are only created if the user was forwarded to an Identity Provider.

haemmer's avatar
haemmer committed
114
115
116
117
118
119
120
121
- {DATE}             = Date of request, e.g. 2010-11-02
- {TIME}             = Time of request, e.g. 06:25:13
- {IP}               = IP of requester, e.g. 127.0.0.1
- {IDP-SELECTION}    = How the IdP was selected: Cookie or Request
- {REQUEST-TYPE}     = Type of request: DS, WAYF, Embedded-DS, Embedded-WAYF
- {IDP-ENTITYID}     = EntityID of the IdP the user was forwarded to.
- {FORWARDING-URL}   = URL the user was redirected to
- {SP-ENTITYID}      = EntityID of the SP the user was coming from.
122
123
124

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
125
126
127
Optimizations
-------------

128
129
130
131
132
133
134
135
136
137
If your instance of the SWITCHwayf has to deal with many requests and the load 
is becoming  higher and higher, you might want to think about using a PHP opcode 
cacher like XCache, apc,  eaccelerator,  phpa,  truck-mmcache or similar.  

Using such a tool can decrease the processing time of the PHP code almost by 
half. However, own tests have shown that the bottleneck in general is not 
the PHP processing but the TLS handshake, which has nothing to do with PHP 
or the SWITCHwayf itself. 

Benchmark tests conducted by SWITCH demonstrated that generating the 
haemmer's avatar
haemmer committed
138
Javascript WAYF/embedded-wayf.js can be speed up using XCache by 100% if the 
139
140
141
142
143
144
script is accessed via HTTP (without TLS). However, if the script is 
accessed via HTTPS (default in SWITCHaai), the overall speed gain by using 
XCache is less than 1% because the TLS hand-shake is what consumes most CPU time.

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
145
146
147
SAML2 Metadata support
----------------------

haemmer's avatar
haemmer committed
148
In case the WAYF/DS should display the list of IdPs by parsing them from a
149
150
151
SAML2 Medatadata file that is used by Shibboleth:

- Set $useSAML2Metadata in config.php to true
haemmer's avatar
haemmer committed
152
- Specify the path to the metadata file that should be read in $metadataFile
153
154
155
156
157
158
  and make sure this file is updated regularely by Shibboleth or a cron job
- Make sure the files specified in $metadataIDPFile and $metadataSPFile can be 
  written by the userthat executes the PHP script (the web server user, 
  e.g. www-data or _www)

The parsend IDP and SP entries will be stored in $metadataIDPFile and 
haemmer's avatar
haemmer committed
159
160
$metadataSPFile as executable PHP code, thus benefiting from opcode caching
(see chapter "Optimization" above).
161

haemmer's avatar
haemmer committed
162
If an entry should changed, removed or extended in this automatically 
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
generated file, one can extend the IDP definitions by modifying them in 
the $IDPConfigFile. To overwrite IDP values with entries in the $IDPConfigFile, 
make sure the entry $SAML2MetaOverLocalConf is set to 'false';
For example one could change the displayed name of an IdP by adding an entry in
the file $IDPConfigFile like:

$IDProviders["https://sso.example.org/idp/shibboleth"]["Name"] = "Foobar";

It is also possible to manually force the IdP list being upgraded by running the 
readMetadata.php in command line mode, e.g. by executing a cron script like:

5 * * * * /usr/bin/php readMetadata.php > /dev/null

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
178
179
180
Embedded WAYF support
---------------------

181
182
183
184
185
186
187
188
189
190
191
192
193
194
With the embedded WAYF support administrators of a Shibboleth protected 
application can easily integrate a Discovery Service on the any page of their 
application just by copying and adapting the HTML code snippet generated by the
SWITCHwayf via the URL /WAYF/embedded-wayf.js/snippet.html

The embedded WAYF then will display on the remote site a drop-down list with the
Identity Provider to authenticate.

One can also configure the embedded WAYF to hide or add Identity Providers 
(even from remote federations) or adapt the look and feel of the embedded wayf. 
This can be done by simpling modifying the JavaScript variables in the HTML 
snippet.


haemmer's avatar
haemmer committed
195
**Note**
196
When activating the Embedded WAYF, carefully protect the host where the WAYF is 
haemmer's avatar
haemmer committed
197
198
199
operated on. If an instance of SWITCHwayf gets compromised, an attacker could 
modify the JavaScript that is embedded on the remote site in a malicous wayf 
(e.g. phish the user's password, redirect users to malicous pages, steal their 
haemmer's avatar
haemmer committed
200
sessions etc).  
haemmer's avatar
haemmer committed
201
202
One also has to ensure that a centrally operated WAYF has a very high availability 
because many services will depend on it.
203
204
205
206
207
208
209

Also, please be aware that using the Embedded WAYF allows anybody to guess a 
user's Home Organisation without much effort. This information then could be 
used for phising attacks for example!

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
210
211
212
Embedded WAYF code HTML snippet
-------------------------------

haemmer's avatar
haemmer committed
213
To get a sample HTML snippet to embedd in a web page, please access the WAYF 
214
215
with a URL like:

haemmer's avatar
haemmer committed
216
https://{HOSTNAME}/{PATH-TO-WAYF}/WAYF/embedded-wayf.js/snippet.html
217
218
219
220
221

The script should return HTML code that can be embedded together with short 
descriptions of the available settings.

Embedded WAYF code limitations:
haemmer's avatar
haemmer committed
222

haemmer's avatar
haemmer committed
223
224
225
226
227
228
* If the embedded WAYF is placed on the right side or at the bottom of a web page,
  it may be that the web browser cannot expand and render the complete drop-down
  list of Identity Providers.
* If placed on a host where no Service Provider is installed, the Embedded WAYF
  might not be able to detect whether a user is logged in or not. Also, the 
  wayf_use_disco_feed might not be used. 
229
230
231

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
232
233
234
Kerberos support
----------------

haemmer's avatar
haemmer committed
235
If this features is used, the web server needs to support Negotiate/SPNEGO 
236
237
238
239
240
241
242
243
244
245
Kerberos protocol. For example by using mod_auth_kerb.
- Make a symlink of the file 'WAYF' and name it like configured in the variable 
  $kerberosRedirectURL
- Protect file $kerberosRedirectURL with Kerberos. The Kerberos realm must be
  specified in "IDProvider.conf.php" for each IdP. Each IdP's KDC must also
  establish a Kerberos cross-realm trust with the WAYF's KDC. This was tested 
  with a Windows 2000 KDC, with the WAYF running on RHEL4. 

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
246
247
248
Configuration file format
-------------------------

249
250
251
Have a look at the file 'IDProvider.conf.php' for an example of the file format 
that is used to configure the list of Identity Provider to display. It's 
supposed to be mostly self-explanatory. Basically the file format is PHP code 
haemmer's avatar
haemmer committed
252
that defines an array of arrays called $IDProviders. 
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275

The keys of the array $IDProviders must correspond to the entityIDs of the 
Identity Providers or a unique value in case of a cascaded WAYF/DS or 
a category. The entityID must be a valid URI (URL or URN) where in the
case of a URN the last component must be a valid hostname.

If metadata is not parsed from SAML2 metadta (using the setting 
$useSAML2Metadata = false), the IdPs and category entries will be displayed 
in order as defined in the configuration file and no sorting is done.

If metadata is used ($useSAML2Metadata = true) to generate the list of Identity 
Providers, the Identity Providers will first be sorted according to their 
type/category, their Index value (see below) and then alphabetically after their 
(local) Name within the same type category. 
If an IdP does not have a type, its category is 'unknown'.
If there exists a type for an IdP that does not have a corresponding category 
it will be displayed in the category 'unknown' at the end of the drop down list 
but will keep its type value (this is important for the Embedded Discovery 
Service).

A general entry for an Identity Provider, a cascaded WAYF/DS or a category is 
of the following form:

haemmer's avatar
haemmer committed
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
$IDProviders[{KEY}] = {ENTRY}

* {KEY}is a unique value that must correspond to the entity's entityID in case 
  the entry stands for an Identity Provider. For entries of Type category, the
  {KEY'} should be an identifier that corresponds to a 'Type' of an IdP.

* '{ENTRY} is a hash array with the following keys: 

  * ['Type']:   Optional  
    Type that is used for the embedded wayf to hide or show certain categories. 
    Default type will be 'unknown' if not specified.  
    An entry for another WAYF/DS that the user should be redirected to should 
    have ['Type'] ='wayf  
    The Type values 'category' and 'wayf' are reserved words that are not allowed
    to be assigned to entries for Identity Providers.
  
  * ['Name']:   Mandatory  
    Default name to display in drop-down list
  
  * [{LANG}]:   Optional  
    {LANG} is a language identifier, e.g. 'en-GB', 'it', 'fr-F', 'de', ...  
    The value is an array with the following keys:
    - ['Name']:     Optional  
      Display name
    - ['Keywords']: Optional  
      Keywords associated with the Identity Provider.  
      Used for search-as-you-type feature of improved drop-down list. Space delimited.
  
  * ['SSO']:    Mandatory  
    Should be the SAML1 SSO endpoint of the IdP
  * ['Realm']:  Optional  
    Kerberos Realm
  * ['IP'][]:   Optional  
    IP ranges of that organizations that can be used to guess a user's Identity 
     Provider
  * ['Index']:  Optional  
    An alphanumerical value that is used for sorting categories and Identity 
    Provider in ascending order if the Identity Providers are parsed from metadata.  
    This is only relevant if $includeLocalConfEntries = true
315

316

haemmer's avatar
haemmer committed
317
318
For category entries, only Type, (local) Name and Index are relevant.
The format for the file $metadataSPFile is very similar. 
319
320
321
A general entry for an Identity Provider, a cascaded WAYF/DS or a category is 
of the following form:

haemmer's avatar
haemmer committed
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
$metadataSProviders[{KEY}] = {ENTRY}

* {KEY} is a unique value that must correspond to the Service Provider's entityID.

* 'ENTRY} is a hash array with the following keys: 

  * ['Name']:       Mandatory  
    Default name to display in drop-down list. By default the MDUI:DisplayName, 
    the ServiceName or the entityID is used. If there is a display name 
    available in the WAYF's default language that one will be used. Otherwise 
    English or the only  available DisplayName is used.
  
  * [{LANG}]:   Optional  
    {LANG} is a language identifier, e.g. 'en-GB', 'it', 'fr-F', 'de', ...  
    The value is an array with the following keys:
    - ['Name']:     Optional  
      Display name
  
  * ['DSURL']:      Optional  
    List of DiscoveryService endpoints of the SP.
  
  * ['ACURL']:      Mandatory   
    List of Assertion Consumer endpoints of the SP.
  
  * ['Protocols']:  Mandatory   
    Protocols supported by the SP, e.g.: urn:oasis:names:tc:SAML:2.0:protocol
    urn:oasis:names:tc:SAML:1.1:protocol
349
350
351

-------------------------------------------------------------------------------

haemmer's avatar
haemmer committed
352
353
354
Path Info parameters and files
------------------------------

355
356
357
358
Modifying the WAYF's URL it is possible to influence its behaviour. This can be
done by appending certain Path Info extension to the URL. The Path Info 
components can also be combined. The allowed syntax is:

haemmer's avatar
haemmer committed
359
360
361
362
363
364
365
366
367
368
369
* [/{I18N-STRING}][/redirect][/{ENTITYID-HOSTNAME}]
* [/{I18N-STRING}][/embedded-wayf.js]
* [/embedded-wayf.js/snippet.html]
* [/IDProviders.json]
* [/IDProviders.php]
* [/IDProviders.txt]

**Note:** 
The web server must support the use of Path Info.

-------------------------------------------------------------------------------
370
371
372
373


Hinted Identity Provider and transparent redirects
--------------------------------------------------
haemmer's avatar
haemmer committed
374
Path Info Extensions: [/redirect][/{ENTITYID-HOSTNAME}]
375

haemmer's avatar
haemmer committed
376
{ENTITYID-HOSTNAME} must be the host name of an entityId or the last component 
377
378
of a URN. Examples:

haemmer's avatar
haemmer committed
379
380
381
382
* https://aai-login.switch.ch/idp/shibboleth         -> aai-login.switch.ch
* urn:mace:switch.ch:aaitest:aai-demo-idp.switch.ch  -> aai-demo-idp.switch.ch

If '/redirect' is included in the Path Info as well, the web browser is 
383
384
redirected transparently to the specified entityID hostname.

haemmer's avatar
haemmer committed
385
386
387
388
389
390
**Note**
One must make sure that the entityID hostname is not the same as one of
the reserved keywords like 'redirect', the below mentioned file types
or a i18n langauge abbreviation.

-------------------------------------------------------------------------------
391
392
393

Language preselection:
----------------------
haemmer's avatar
haemmer committed
394
Path Info Extensions: [/{I18N-STRING}]
395

haemmer's avatar
haemmer committed
396
397
398
399
400
Examples of {I18N-STRING} strings are 'en', 'de_CH' or 'fr_CH.ISO8859-1' etc. 
However, in the default distribution only 'en', 'de', 'fr', 'it' and 'pt' are 
available and  supported. But it would be easy to create sub types of existing 
languages  for country/region support by adding something like this to 
languages.php:
401

haemmer's avatar
haemmer committed
402
403

// Create a country specific copy of the German language strings  
404
405
$langStrings['de_CH'] = $langStrings['de'];

haemmer's avatar
haemmer committed
406
// Overwrite a specific string  
407
408
$langStrings['de_CH']['title'] = 'Auswahl der Heimorganisation';

haemmer's avatar
haemmer committed
409
-------------------------------------------------------------------------------
410
411
412
413
414
415
416
417

Special handlers:
-----------------
In order for the Embedded WAYF feature to work there are some special files that
need to be generated. The following Path Info Extensions must be the last 
components of the Path Info URL.

Path Info Extensions:
haemmer's avatar
haemmer committed
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444

* [/deleteSettings]  
  As the name suggests, this handler delete all settings cookies that were stored 
  by the WAYF service in cookies. Unless there is a 'return' GET argument 
  provided the user is sent to the settings page.

* [/embedded-wayf.js]  
  Generates the JavaScript for the Embedded WAYF

* [/embedded-wayf.js/snippet.html  
  Generates HTML snippet for the Embedded WAYF

* [/ShibbolethDS-IDProviders.js]  
  Returns JavaScript consisting of only a variable called myJSONObject. It 
  contains the IDProviders array. If $exportPreselectedIdP = true, the last
  element of that array will be a key called 'preselectedIDP', which contains 
  the  Identity Provider that would be preselected in the drop-down list for 
  that user.

* [/ShibbolethDS-IDProviders.json]  
  Same as above but as a JSON data array.

* [/IDProviders.txt]  
  Same as above but in human readable form.

* [/IDProviders.php]  
  Same as above but as PHP code
445