~corey.bryant/ubuntu/wily/python-pysaml2/3.0.0

« back to all changes in this revision

Viewing changes to doc/howto/config.rst

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2014-09-08 16:11:53 UTC
  • Revision ID: package-import@ubuntu.com-20140908161153-vms9r4gu0oz4v4ai
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. _howto_config:
 
2
 
 
3
Configuration of pySAML2 entities
 
4
=================================
 
5
 
 
6
Whether you plan to run a pySAML2 Service Provider, Identity provider or an
 
7
attribute authority you have to configure it. The format of the configuration
 
8
file is the same disregarding which type of service you plan to run.
 
9
What differs is some of the directives.
 
10
Below you will find a list of all the used directives in alphabetic order.
 
11
The configuration is written as a python module which contains a named
 
12
dictionary ("CONFIG") that contains the configuration directives.
 
13
 
 
14
The basic structure of the configuration file is therefor like this::
 
15
 
 
16
    from saml2 import BINDING_HTTP_REDIRECT
 
17
 
 
18
    CONFIG = {
 
19
        "entityid" : "http://saml.example.com:saml/idp.xml",
 
20
        "name" : "Rolands IdP",
 
21
        "service": {
 
22
            "idp": {
 
23
                "endpoints" : {
 
24
                    "single_sign_on_service" : [
 
25
                            ("http://saml.example.com:saml:8088/sso",
 
26
                                BINDING_HTTP_REDIRECT)],
 
27
                    "single_logout_service": [
 
28
                            ("http://saml.example.com:saml:8088/slo",
 
29
                                BINDING_HTTP_REDIRECT)]
 
30
                },
 
31
                ...
 
32
            }
 
33
        },
 
34
        "key_file" : "my.key",
 
35
        "cert_file" : "ca.pem",
 
36
        "xmlsec_binary" : "/usr/local/bin/xmlsec1",
 
37
        "metadata": {
 
38
            "local": ["edugain.xml"],
 
39
        },
 
40
        "attribute_map_dir" : "attributemaps",
 
41
        ...
 
42
    }
 
43
 
 
44
.. note:: You can build the metadata file for your services directly from the
 
45
    configuration.The make_metadata.py script in the pySAML2 tools directory
 
46
    will do that for you.
 
47
 
 
48
Configuration directives
 
49
::::::::::::::::::::::::
 
50
 
 
51
.. contents::
 
52
    :local:
 
53
    :backlinks: entry
 
54
 
 
55
General directives
 
56
------------------
 
57
 
 
58
attribute_map_dir
 
59
^^^^^^^^^^^^^^^^^
 
60
 
 
61
Format::
 
62
 
 
63
    "attribute_map_dir": "attribute-maps"
 
64
    
 
65
Points to a directory which has the attribute maps in Python modules.
 
66
A typical map file will looks like this::
 
67
 
 
68
    MAP = {
 
69
        "identifier": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic",
 
70
        "fro": {
 
71
            'urn:mace:dir:attribute-def:aRecord': 'aRecord',
 
72
            'urn:mace:dir:attribute-def:aliasedEntryName': 'aliasedEntryName',
 
73
            'urn:mace:dir:attribute-def:aliasedObjectName': 'aliasedObjectName',
 
74
            'urn:mace:dir:attribute-def:associatedDomain': 'associatedDomain',
 
75
            'urn:mace:dir:attribute-def:associatedName': 'associatedName',
 
76
            ...
 
77
            },
 
78
        "to": {
 
79
            'aRecord': 'urn:mace:dir:attribute-def:aRecord',
 
80
            'aliasedEntryName': 'urn:mace:dir:attribute-def:aliasedEntryName',
 
81
            'aliasedObjectName': 'urn:mace:dir:attribute-def:aliasedObjectName',
 
82
            'associatedDomain': 'urn:mace:dir:attribute-def:associatedDomain',
 
83
            'associatedName': 'urn:mace:dir:attribute-def:associatedName',
 
84
            ...
 
85
        }
 
86
    }
 
87
 
 
88
The attribute map module contains a MAP dictionary with three items.  The
 
89
`identifier` item is the name-format you expect to support.
 
90
The *to* and *fro* sub-dictionaries then contain the mapping between the names.
 
91
 
 
92
As you see the format is again a python dictionary where the key is the
 
93
name to convert from and the value is the name to convert to.
 
94
    
 
95
Since *to* in most cases are the inverse of the *fro* file, the 
 
96
software allowes you to only specify one of them and it will 
 
97
automatically create the other.
 
98
 
 
99
cert_file
 
100
^^^^^^^^^
 
101
 
 
102
Format::
 
103
 
 
104
    cert_file: "cert.pem"
 
105
 
 
106
This is the public part of the service private/public key pair.
 
107
*cert_file* must be a PEM formatted certificate chain file.
 
108
 
 
109
contact_person
 
110
^^^^^^^^^^^^^^
 
111
 
 
112
This is only used by *make_metadata.py* when it constructs the metadata for 
 
113
the service described by the configuration file.
 
114
This is where you described who can be contacted if questions arises
 
115
about the service or if support is needed. The possible types are according to
 
116
the standard **technical**, **support**, **administrative**, **billing** 
 
117
and **other**.::
 
118
 
 
119
    contact_person: [{
 
120
        "givenname": "Derek",
 
121
        "surname": "Jeter",
 
122
        "company": "Example Co.",
 
123
        "mail": ["jeter@example.com"],
 
124
        "type": "technical",
 
125
    },{
 
126
        "givenname": "Joe",
 
127
        "surname": "Girardi",
 
128
        "company": "Example Co.",
 
129
        "mail": "girardi@example.com",
 
130
        "type": "administrative",
 
131
    }]
 
132
 
 
133
debug
 
134
^^^^^
 
135
 
 
136
Format::
 
137
 
 
138
    debug: 1
 
139
 
 
140
Whether debug information should be sent to the log file.
 
141
 
 
142
entityid
 
143
^^^^^^^^
 
144
 
 
145
Format::
 
146
 
 
147
    entityid: "http://saml.example.com/sp"
 
148
 
 
149
The globally unique identifier of the entity.
 
150
 
 
151
.. note:: There is a recommendation that the entityid should point to a real
 
152
    webpage where the metadata for the entity can be found.
 
153
 
 
154
key_file
 
155
^^^^^^^^
 
156
 
 
157
Format::
 
158
 
 
159
    key_file: "key.pem"
 
160
 
 
161
*key_file* is the name of a PEM formatted file that contains the private key
 
162
of the service. This is presently used both to encrypt/sign assertions and as
 
163
client key in a HTTPS session.
 
164
 
 
165
metadata
 
166
^^^^^^^^
 
167
 
 
168
Contains a list of places where metadata can be found. This can be either
 
169
a file accessible on the server the service runs on or somewhere on the net.::
 
170
 
 
171
    "metadata" : {
 
172
        "local": [
 
173
            "metadata.xml", "vo_metadata.xml"
 
174
            ],
 
175
        "remote": [
 
176
            {
 
177
                "url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
 
178
                "cert":"kalmar2.cert"
 
179
            }],
 
180
    },
 
181
 
 
182
The above configuration means that the service should read two local 
 
183
metadata files and on top of that load one from the net. To verify the
 
184
authenticity of the file downloaded from the net the local copy of the 
 
185
public key should be used.
 
186
This public key must be acquired by some out-of-band method.
 
187
 
 
188
organization
 
189
^^^^^^^^^^^^
 
190
 
 
191
Only used by *make_metadata.py*.
 
192
Where you describe the organization responsible for the service.::
 
193
 
 
194
    "organization": {
 
195
        "name": [("Example Company","en"), ("Exempel AB","se")],
 
196
        "display_name": ["Exempel AB"],
 
197
        "url": [("http://example.com","en"),("http://exempel.se","se")],
 
198
    }
 
199
 
 
200
.. note:: You can specify the language of the name, or the language used on
 
201
    the webpage, by entering a tuple, instead of a simple string, 
 
202
    where the second part is the language code. If you don't specify a
 
203
    language the default is "en" (English).
 
204
 
 
205
service
 
206
^^^^^^^
 
207
 
 
208
Which services the server will provide, those are combinations of "idp","sp" 
 
209
and "aa".
 
210
So if a server is a Service Provider (SP) then the configuration 
 
211
could look something like this::
 
212
 
 
213
    "service": {
 
214
        "sp":{
 
215
            "name" : "Rolands SP",
 
216
            "endpoints":{
 
217
                "assertion_consumer_service": ["http://localhost:8087/"],
 
218
                "single_logout_service" : [("http://localhost:8087/slo",
 
219
                               'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect')],
 
220
            },
 
221
            "required_attributes": ["surname", "givenname", "edupersonaffiliation"],
 
222
            "optional_attributes": ["title"],
 
223
            "idp": {
 
224
                "urn:mace:umu.se:saml:roland:idp": None,
 
225
            },
 
226
        }
 
227
    },
 
228
    
 
229
There are two options common to all services: 'name' and 'endpoints'.
 
230
The remaining options are specific to one or the other of the service types.
 
231
Which one is specified along side the name of the option
 
232
 
 
233
timeslack
 
234
^^^^^^^^^
 
235
 
 
236
If your computer and another computer that you are communicating with are not
 
237
in synch regarding the computer clock. Then you here can state how big a
 
238
difference you are prepared to accept.
 
239
 
 
240
.. note:: This will indiscriminately effect all time comparisons.
 
241
    Hence your server my accept a statement that in fact is to old.
 
242
 
 
243
xmlsec_binary
 
244
^^^^^^^^^^^^^
 
245
 
 
246
Presently xmlsec1 binaries are used for all the signing and encryption stuff.
 
247
This option defines where the binary is situated.
 
248
 
 
249
Example::
 
250
 
 
251
    "xmlsec_binary": "/usr/local/bin/xmlsec1",
 
252
 
 
253
valid_for
 
254
^^^^^^^^^
 
255
 
 
256
How many *hours* this configuration is expected to be accurate.::
 
257
 
 
258
    "valid_for": 24
 
259
 
 
260
This of course is only used by *make_metadata.py*.
 
261
The server will not stop working when this amount of time has elapsed :-).
 
262
 
 
263
Specific directives
 
264
-------------------
 
265
 
 
266
Directives that are specific to a certain type of service.
 
267
 
 
268
idp/aa
 
269
^^^^^^
 
270
 
 
271
Directives that are specific to an IdP or AA service instance
 
272
 
 
273
policy
 
274
""""""
 
275
 
 
276
If the server is an IdP and/or an AA then there might be reasons to do things
 
277
differently depending on who is asking; this is where that is specified.
 
278
The keys are 'default' and SP entity identifiers, default is used whenever
 
279
there is no entry for a specific SP. The reasoning is also that if there is
 
280
no default and only SP entity identifiers as keys, then the server will only
 
281
except connections from the specified SPs.
 
282
An example might be::
 
283
 
 
284
    "service": {
 
285
        "idp": {
 
286
            "policy": {
 
287
                "default": {
 
288
                    "lifetime": {"minutes":15},
 
289
                    "attribute_restrictions": None, # means all I have
 
290
                    "name_form": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
 
291
                },
 
292
                "urn:mace:example.com:saml:roland:sp": {
 
293
                    "lifetime": {"minutes": 5},
 
294
                    "attribute_restrictions":{
 
295
                        "givenName": None,
 
296
                        "surName": None,
 
297
                    }
 
298
                }
 
299
            }
 
300
        }
 
301
    }
 
302
    
 
303
*lifetime* 
 
304
    is the maximum amount of time before the information should be 
 
305
    regarded as stale. In an Assertion this is represented in the NotOnOrAfter 
 
306
    attribute.    
 
307
*attribute_restrictions*
 
308
    By default there is no restrictions as to which attributes should be
 
309
    return. Instead all the attributes and values that is gathered by the 
 
310
    database backends will be returned if nothing else is stated.
 
311
    In the example above the SP with the entity identifier
 
312
    "urn:mace:umu.se:saml:roland:sp" 
 
313
    has an attribute restriction: only the attributes
 
314
    'givenName' and 'surName' are to be returned. There is no limitations as to
 
315
    what values on these attributes that can be returned.
 
316
*name_form*
 
317
    Which name-form that should be used when sending assertions.
 
318
 
 
319
If restrictions on values are deemed necessary those are represented by 
 
320
regular expressions.::
 
321
 
 
322
    "service": {
 
323
        "aa": {
 
324
            "policy": {
 
325
                "urn:mace:umu.se:saml:roland:sp": {
 
326
                    "lifetime": {"minutes": 5},
 
327
                    "attribute_restrictions":{
 
328
                         "mail": [".*\.umu\.se$"],
 
329
                    }
 
330
                }
 
331
            }
 
332
        }
 
333
    }
 
334
 
 
335
Here only mail addresses that ends with ".umu.se" will be returned.
 
336
 
 
337
sp
 
338
^^
 
339
 
 
340
Directives specific to SP instances
 
341
 
 
342
authn_requests_signed
 
343
"""""""""""""""""""""
 
344
 
 
345
Indicates if the Authentication Requests sent by this SP should be signed
 
346
by default. This can be overriden by application code for a specific call.
 
347
 
 
348
This set the AuthnRequestsSigned attribute of the SPSSODescriptor node.
 
349
of the metadata so the IdP will know this SP preference.
 
350
 
 
351
Valid values are "true" or "false". Default value is "false".
 
352
 
 
353
Example::
 
354
 
 
355
    "service": {
 
356
        "sp": {
 
357
            "authn_assertions_signed": "true",
 
358
        }
 
359
    }
 
360
 
 
361
 
 
362
idp
 
363
"""
 
364
 
 
365
Defines the set of IdPs that this SP is allowed to use. If not all the IdPs in
 
366
the metadata is allowed, then the value is expected to be a list with entity
 
367
identifiers for the allowed IdPs.
 
368
A typical configuration, when the allowed set of IdPs are limited, would look
 
369
something like this::
 
370
 
 
371
    "service": {
 
372
        "sp": {
 
373
            "idp": ["urn:mace:umu.se:saml:roland:idp"],
 
374
        }
 
375
    }
 
376
 
 
377
In this case the SP has only one IdP it can use.
 
378
 
 
379
If all IdPs present in the metadata loaded this directive must be left out.
 
380
 
 
381
optional_attributes
 
382
"""""""""""""""""""
 
383
 
 
384
Attributes that this SP would like to receive from IdPs.
 
385
 
 
386
Example::
 
387
 
 
388
    "service": {
 
389
        "sp": {
 
390
            "optional_attributes": ["title"],
 
391
        }
 
392
    }
 
393
    
 
394
Since the attribute names used here are the user friendly ones an attribute map
 
395
must exist, so that the server can use the full name when communicating
 
396
with other servers.
 
397
 
 
398
required_attributes
 
399
"""""""""""""""""""
 
400
 
 
401
Attributes that this SP demands to receive from IdPs.
 
402
 
 
403
Example::
 
404
 
 
405
    "service": {
 
406
        "sp": {
 
407
            "required_attributes": ["surname", "givenName", "mail"],
 
408
        }
 
409
    }
 
410
 
 
411
Again as for *optional_attributes* the names given are expected to be 
 
412
the user friendly names.
 
413
 
 
414
want_assertions_signed
 
415
""""""""""""""""""""""
 
416
 
 
417
Indicates if this SP wants the IdP to send the assertions signed. This
 
418
set the WantAssertionsSigned attribute of the SPSSODescriptor node.
 
419
of the metadata so the IdP will know this SP preference.
 
420
 
 
421
Valid values are "true" or "false". Default value is "true".
 
422
 
 
423
Example::
 
424
 
 
425
    "service": {
 
426
        "sp": {
 
427
            "want_assertions_signed": "true",
 
428
        }
 
429
    }
 
430
 
 
431
 
 
432
idp/aa/sp
 
433
^^^^^^^^^ 
 
434
 
 
435
If the configuration is covering both two or three different service types
 
436
(like if one server is actually acting as both an IdP and a SP) then in some
 
437
cases you might want to have these below different for the different services.
 
438
 
 
439
endpoints
 
440
"""""""""
 
441
 
 
442
Where the endpoints for the services provided are.
 
443
This directive has as value a dictionary with one of the following keys:
 
444
 
 
445
* artifact_resolution_service (aa, idp and sp)
 
446
* assertion_consumer_service (sp)
 
447
* assertion_id_request_service (aa, idp)
 
448
* attribute_service (aa)
 
449
* manage_name_id_service (aa, idp)
 
450
* name_id_mapping_service (idp)
 
451
* single_logout_service (aa, idp, sp)
 
452
* single_sign_on_service (idp)
 
453
 
 
454
The values per service is a list of tuples containing endpoint and binding
 
455
type.
 
456
 
 
457
Example::
 
458
 
 
459
    "service":
 
460
        "idp": {
 
461
            "endpoints" : {
 
462
                "single_sign_on_service" : [
 
463
                        ("http://localhost:8088/sso", BINDING_HTTP_REDIRECT)],
 
464
                "single_logout_service": [
 
465
                        ("http://localhost:8088/slo", BINDING_HTTP_REDIRECT)]
 
466
            },
 
467
        },
 
468
    },
 
469
 
 
470
logout_requests_signed
 
471
""""""""""""""""""""""
 
472
 
 
473
Indicates if this entity will sign the Logout Requests originated from it.
 
474
 
 
475
This can be overriden by application code for a specific call.
 
476
 
 
477
Valid values are "true" or "false". Default value is "false"
 
478
 
 
479
Example::
 
480
 
 
481
    "service": {
 
482
        "sp": {
 
483
            "logout_requests_signed": "true",
 
484
        }
 
485
    }
 
486
 
 
487
subject_data
 
488
""""""""""""
 
489
 
 
490
The name of a database where the map between a local identifier and 
 
491
a distributed identifier is kept. By default this is a shelve database.
 
492
So if you just specify name, then a shelve database with that name
 
493
is created. On the other hand if you specify a tuple then the first
 
494
element in the tuple specifise which type of database you want to use
 
495
and the second element is the address of the database.
 
496
 
 
497
Example::
 
498
 
 
499
    "subject_data": "./idp.subject.db",
 
500
 
 
501
or if you want to use for instance memcache::
 
502
 
 
503
    "subject_data": ("memcached", "localhost:12121"),
 
504
 
 
505
*shelve* and *memcached* are the only database types that are presently
 
506
supported.
 
507
 
 
508
 
 
509
virtual_organization
 
510
""""""""""""""""""""
 
511
 
 
512
Gives information about common identifiers for virtual_organizations::
 
513
 
 
514
    "virtual_organization" : {
 
515
        "urn:mace:example.com:it:tek":{
 
516
            "nameid_format" : "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
 
517
            "common_identifier": "umuselin",
 
518
        }
 
519
    },
 
520
 
 
521
Keys in this dictionary are the identifiers for the virtual organizations.
 
522
The arguments per organization is 'nameid_format' and 'common_identifier'. 
 
523
Useful if all the IdPs and AAs that are involved in a virtual organization 
 
524
have common attribute values for users that are part of the VO.
 
525
 
 
526
Complete example
 
527
----------------
 
528
 
 
529
We start with a simple but fairly complete Service provider configuration::
 
530
 
 
531
    from saml2 import BINDING_HTTP_REDIRECT
 
532
 
 
533
    CONFIG = {
 
534
        "entityid" : "http://example.com/sp/metadata.xml",
 
535
        "service": {
 
536
            "sp":{
 
537
                "name" : "Example SP",
 
538
                "endpoints":{
 
539
                    "assertion_consumer_service": ["http://example.com/sp"],
 
540
                    "single_logout_service" : [("http://example.com/sp/slo",
 
541
                                                BINDING_HTTP_REDIRECT)],
 
542
                },
 
543
            }
 
544
        },
 
545
        "key_file" : "./mykey.pem",
 
546
        "cert_file" : "./mycert.pem",
 
547
        "xmlsec_binary" : "/usr/local/bin/xmlsec1",
 
548
        "attribute_map_dir": "./attributemaps",
 
549
        "metadata": {
 
550
            "local": ["idp.xml"]
 
551
        }
 
552
        "organization": {
 
553
            "display_name":["Example identities"]
 
554
        }
 
555
        "contact_person": [{
 
556
            "givenname": "Roland",
 
557
            "surname": "Hedberg",
 
558
            "phone": "+46 90510",
 
559
            "mail": "roland@example.com",
 
560
            "type": "technical",
 
561
            }]
 
562
    }
 
563
 
 
564
This is the typical setup for a SP.
 
565
A metadata file to load is *always* needed, but it can of course be
 
566
containing anything from 1 up to many entity descriptions.
 
567
 
 
568
------
 
569
 
 
570
A slightly more complex configuration::
 
571
 
 
572
    from saml2 import BINDING_HTTP_REDIRECT
 
573
 
 
574
    CONFIG = {
 
575
        "entityid" : "http://sp.example.com/metadata.xml",
 
576
        "service": {
 
577
            "sp":{
 
578
                "name" : "Example SP",
 
579
                "endpoints":{
 
580
                    "assertion_consumer_service": ["http://sp.example.com/"],
 
581
                    "single_logout_service" : [("http://sp.example.com/slo",
 
582
                                   BINDING_HTTP_REDIRECT)],
 
583
                },
 
584
                "subject_data": ("memcached", "localhost:12121"),
 
585
                "virtual_organization" : {
 
586
                    "urn:mace:example.com:it:tek":{
 
587
                        "nameid_format" : "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
 
588
                        "common_identifier": "eduPersonPrincipalName",
 
589
                    }
 
590
                },
 
591
            }
 
592
        },
 
593
        "key_file" : "./mykey.pem",
 
594
        "cert_file" : "./mycert.pem",
 
595
        "xmlsec_binary" : "/usr/local/bin/xmlsec1",
 
596
        "metadata" : { 
 
597
            "local": ["example.xml"],
 
598
            "remote": [{ 
 
599
                "url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
 
600
                "cert":"kalmar2.pem"}]
 
601
        },
 
602
        "attribute_maps" : "attributemaps",
 
603
        "organization": {
 
604
            "display_name":["Example identities"]
 
605
        }
 
606
        "contact_person": [{
 
607
            "givenname": "Roland",
 
608
            "surname": "Hedberg",
 
609
            "phone": "+46 90510",
 
610
            "mail": "roland@example.com",
 
611
            "type": "technical",
 
612
            }]
 
613
    }
 
614
    
 
615
Uses metadata files, both local and remote, and will talk to whatever 
 
616
IdP that appears in any of the metadata files.