File: config.rst

package info (click to toggle)
python-pysaml2 2.0.0-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 26,352 kB
  • ctags: 11,612
  • sloc: xml: 219,044; python: 50,122; makefile: 106; sh: 18
file content (616 lines) | stat: -rw-r--r-- 18,780 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
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
315
316
317
318
319
320
321
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
.. _howto_config:

Configuration of pySAML2 entities
=================================

Whether you plan to run a pySAML2 Service Provider, Identity provider or an
attribute authority you have to configure it. The format of the configuration
file is the same disregarding which type of service you plan to run.
What differs is some of the directives.
Below you will find a list of all the used directives in alphabetic order.
The configuration is written as a python module which contains a named
dictionary ("CONFIG") that contains the configuration directives.

The basic structure of the configuration file is therefor like this::

    from saml2 import BINDING_HTTP_REDIRECT

    CONFIG = {
        "entityid" : "http://saml.example.com:saml/idp.xml",
        "name" : "Rolands IdP",
        "service": {
            "idp": {
                "endpoints" : {
                    "single_sign_on_service" : [
                            ("http://saml.example.com:saml:8088/sso",
                                BINDING_HTTP_REDIRECT)],
                    "single_logout_service": [
                            ("http://saml.example.com:saml:8088/slo",
                                BINDING_HTTP_REDIRECT)]
                },
                ...
            }
        },
        "key_file" : "my.key",
        "cert_file" : "ca.pem",
        "xmlsec_binary" : "/usr/local/bin/xmlsec1",
        "metadata": {
            "local": ["edugain.xml"],
        },
        "attribute_map_dir" : "attributemaps",
        ...
    }

.. note:: You can build the metadata file for your services directly from the
    configuration.The make_metadata.py script in the pySAML2 tools directory
    will do that for you.

Configuration directives
::::::::::::::::::::::::

.. contents::
    :local:
    :backlinks: entry

General directives
------------------

attribute_map_dir
^^^^^^^^^^^^^^^^^

Format::

    "attribute_map_dir": "attribute-maps"
    
Points to a directory which has the attribute maps in Python modules.
A typical map file will looks like this::

    MAP = {
        "identifier": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic",
        "fro": {
            'urn:mace:dir:attribute-def:aRecord': 'aRecord',
            'urn:mace:dir:attribute-def:aliasedEntryName': 'aliasedEntryName',
            'urn:mace:dir:attribute-def:aliasedObjectName': 'aliasedObjectName',
            'urn:mace:dir:attribute-def:associatedDomain': 'associatedDomain',
            'urn:mace:dir:attribute-def:associatedName': 'associatedName',
            ...
            },
        "to": {
            'aRecord': 'urn:mace:dir:attribute-def:aRecord',
            'aliasedEntryName': 'urn:mace:dir:attribute-def:aliasedEntryName',
            'aliasedObjectName': 'urn:mace:dir:attribute-def:aliasedObjectName',
            'associatedDomain': 'urn:mace:dir:attribute-def:associatedDomain',
            'associatedName': 'urn:mace:dir:attribute-def:associatedName',
            ...
        }
    }

The attribute map module contains a MAP dictionary with three items.  The
`identifier` item is the name-format you expect to support.
The *to* and *fro* sub-dictionaries then contain the mapping between the names.

As you see the format is again a python dictionary where the key is the
name to convert from and the value is the name to convert to.
    
Since *to* in most cases are the inverse of the *fro* file, the 
software allowes you to only specify one of them and it will 
automatically create the other.

cert_file
^^^^^^^^^

Format::

    cert_file: "cert.pem"

This is the public part of the service private/public key pair.
*cert_file* must be a PEM formatted certificate chain file.

contact_person
^^^^^^^^^^^^^^

This is only used by *make_metadata.py* when it constructs the metadata for 
the service described by the configuration file.
This is where you described who can be contacted if questions arises
about the service or if support is needed. The possible types are according to
the standard **technical**, **support**, **administrative**, **billing** 
and **other**.::

    contact_person: [{
        "givenname": "Derek",
        "surname": "Jeter",
        "company": "Example Co.",
        "mail": ["jeter@example.com"],
        "type": "technical",
    },{
        "givenname": "Joe",
        "surname": "Girardi",
        "company": "Example Co.",
        "mail": "girardi@example.com",
        "type": "administrative",
    }]

debug
^^^^^

Format::

    debug: 1

Whether debug information should be sent to the log file.

entityid
^^^^^^^^

Format::

    entityid: "http://saml.example.com/sp"

The globally unique identifier of the entity.

.. note:: There is a recommendation that the entityid should point to a real
    webpage where the metadata for the entity can be found.

key_file
^^^^^^^^

Format::

    key_file: "key.pem"

*key_file* is the name of a PEM formatted file that contains the private key
of the service. This is presently used both to encrypt/sign assertions and as
client key in a HTTPS session.

metadata
^^^^^^^^

Contains a list of places where metadata can be found. This can be either
a file accessible on the server the service runs on or somewhere on the net.::

    "metadata" : {
        "local": [
            "metadata.xml", "vo_metadata.xml"
            ],
        "remote": [
            {
                "url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
                "cert":"kalmar2.cert"
            }],
    },

The above configuration means that the service should read two local 
metadata files and on top of that load one from the net. To verify the
authenticity of the file downloaded from the net the local copy of the 
public key should be used.
This public key must be acquired by some out-of-band method.

organization
^^^^^^^^^^^^

Only used by *make_metadata.py*.
Where you describe the organization responsible for the service.::

    "organization": {
        "name": [("Example Company","en"), ("Exempel AB","se")],
        "display_name": ["Exempel AB"],
        "url": [("http://example.com","en"),("http://exempel.se","se")],
    }

.. note:: You can specify the language of the name, or the language used on
    the webpage, by entering a tuple, instead of a simple string, 
    where the second part is the language code. If you don't specify a
    language the default is "en" (English).

service
^^^^^^^

Which services the server will provide, those are combinations of "idp","sp" 
and "aa".
So if a server is a Service Provider (SP) then the configuration 
could look something like this::

    "service": {
        "sp":{
            "name" : "Rolands SP",
            "endpoints":{
                "assertion_consumer_service": ["http://localhost:8087/"],
                "single_logout_service" : [("http://localhost:8087/slo",
                               'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect')],
            },
            "required_attributes": ["surname", "givenname", "edupersonaffiliation"],
            "optional_attributes": ["title"],
            "idp": {
                "urn:mace:umu.se:saml:roland:idp": None,
            },
        }
    },
    
There are two options common to all services: 'name' and 'endpoints'.
The remaining options are specific to one or the other of the service types.
Which one is specified along side the name of the option

timeslack
^^^^^^^^^

If your computer and another computer that you are communicating with are not
in synch regarding the computer clock. Then you here can state how big a
difference you are prepared to accept.

.. note:: This will indiscriminately effect all time comparisons.
    Hence your server my accept a statement that in fact is to old.

xmlsec_binary
^^^^^^^^^^^^^

Presently xmlsec1 binaries are used for all the signing and encryption stuff.
This option defines where the binary is situated.

Example::

    "xmlsec_binary": "/usr/local/bin/xmlsec1",

valid_for
^^^^^^^^^

How many *hours* this configuration is expected to be accurate.::

    "valid_for": 24

This of course is only used by *make_metadata.py*.
The server will not stop working when this amount of time has elapsed :-).

Specific directives
-------------------

Directives that are specific to a certain type of service.

idp/aa
^^^^^^

Directives that are specific to an IdP or AA service instance

policy
""""""

If the server is an IdP and/or an AA then there might be reasons to do things
differently depending on who is asking; this is where that is specified.
The keys are 'default' and SP entity identifiers, default is used whenever
there is no entry for a specific SP. The reasoning is also that if there is
no default and only SP entity identifiers as keys, then the server will only
except connections from the specified SPs.
An example might be::

    "service": {
        "idp": {
            "policy": {
                "default": {
                    "lifetime": {"minutes":15},
                    "attribute_restrictions": None, # means all I have
                    "name_form": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
                },
                "urn:mace:example.com:saml:roland:sp": {
                    "lifetime": {"minutes": 5},
                    "attribute_restrictions":{
                        "givenName": None,
                        "surName": None,
                    }
                }
            }
        }
    }
    
*lifetime* 
    is the maximum amount of time before the information should be 
    regarded as stale. In an Assertion this is represented in the NotOnOrAfter 
    attribute.    
*attribute_restrictions*
    By default there is no restrictions as to which attributes should be
    return. Instead all the attributes and values that is gathered by the 
    database backends will be returned if nothing else is stated.
    In the example above the SP with the entity identifier
    "urn:mace:umu.se:saml:roland:sp" 
    has an attribute restriction: only the attributes
    'givenName' and 'surName' are to be returned. There is no limitations as to
    what values on these attributes that can be returned.
*name_form*
    Which name-form that should be used when sending assertions.

If restrictions on values are deemed necessary those are represented by 
regular expressions.::

    "service": {
        "aa": {
            "policy": {
                "urn:mace:umu.se:saml:roland:sp": {
                    "lifetime": {"minutes": 5},
                    "attribute_restrictions":{
                         "mail": [".*\.umu\.se$"],
                    }
                }
            }
        }
    }

Here only mail addresses that ends with ".umu.se" will be returned.

sp
^^

Directives specific to SP instances

authn_requests_signed
"""""""""""""""""""""

Indicates if the Authentication Requests sent by this SP should be signed
by default. This can be overriden by application code for a specific call.

This set the AuthnRequestsSigned attribute of the SPSSODescriptor node.
of the metadata so the IdP will know this SP preference.

Valid values are "true" or "false". Default value is "false".

Example::

    "service": {
        "sp": {
            "authn_assertions_signed": "true",
        }
    }


idp
"""

Defines the set of IdPs that this SP is allowed to use. If not all the IdPs in
the metadata is allowed, then the value is expected to be a list with entity
identifiers for the allowed IdPs.
A typical configuration, when the allowed set of IdPs are limited, would look
something like this::

    "service": {
        "sp": {
            "idp": ["urn:mace:umu.se:saml:roland:idp"],
        }
    }

In this case the SP has only one IdP it can use.

If all IdPs present in the metadata loaded this directive must be left out.

optional_attributes
"""""""""""""""""""

Attributes that this SP would like to receive from IdPs.

Example::

    "service": {
        "sp": {
            "optional_attributes": ["title"],
        }
    }
    
Since the attribute names used here are the user friendly ones an attribute map
must exist, so that the server can use the full name when communicating
with other servers.

required_attributes
"""""""""""""""""""

Attributes that this SP demands to receive from IdPs.

Example::

    "service": {
        "sp": {
            "required_attributes": ["surname", "givenName", "mail"],
        }
    }

Again as for *optional_attributes* the names given are expected to be 
the user friendly names.

want_assertions_signed
""""""""""""""""""""""

Indicates if this SP wants the IdP to send the assertions signed. This
set the WantAssertionsSigned attribute of the SPSSODescriptor node.
of the metadata so the IdP will know this SP preference.

Valid values are "true" or "false". Default value is "true".

Example::

    "service": {
        "sp": {
            "want_assertions_signed": "true",
        }
    }


idp/aa/sp
^^^^^^^^^ 

If the configuration is covering both two or three different service types
(like if one server is actually acting as both an IdP and a SP) then in some
cases you might want to have these below different for the different services.

endpoints
"""""""""

Where the endpoints for the services provided are.
This directive has as value a dictionary with one of the following keys:

* artifact_resolution_service (aa, idp and sp)
* assertion_consumer_service (sp)
* assertion_id_request_service (aa, idp)
* attribute_service (aa)
* manage_name_id_service (aa, idp)
* name_id_mapping_service (idp)
* single_logout_service (aa, idp, sp)
* single_sign_on_service (idp)

The values per service is a list of tuples containing endpoint and binding
type.

Example::

    "service":
        "idp": {
            "endpoints" : {
                "single_sign_on_service" : [
                        ("http://localhost:8088/sso", BINDING_HTTP_REDIRECT)],
                "single_logout_service": [
                        ("http://localhost:8088/slo", BINDING_HTTP_REDIRECT)]
            },
        },
    },

logout_requests_signed
""""""""""""""""""""""

Indicates if this entity will sign the Logout Requests originated from it.

This can be overriden by application code for a specific call.

Valid values are "true" or "false". Default value is "false"

Example::

    "service": {
        "sp": {
            "logout_requests_signed": "true",
        }
    }

subject_data
""""""""""""

The name of a database where the map between a local identifier and 
a distributed identifier is kept. By default this is a shelve database.
So if you just specify name, then a shelve database with that name
is created. On the other hand if you specify a tuple then the first
element in the tuple specifise which type of database you want to use
and the second element is the address of the database.

Example::

    "subject_data": "./idp.subject.db",

or if you want to use for instance memcache::

    "subject_data": ("memcached", "localhost:12121"),

*shelve* and *memcached* are the only database types that are presently
supported.


virtual_organization
""""""""""""""""""""

Gives information about common identifiers for virtual_organizations::

    "virtual_organization" : {
        "urn:mace:example.com:it:tek":{
            "nameid_format" : "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
            "common_identifier": "umuselin",
        }
    },

Keys in this dictionary are the identifiers for the virtual organizations.
The arguments per organization is 'nameid_format' and 'common_identifier'. 
Useful if all the IdPs and AAs that are involved in a virtual organization 
have common attribute values for users that are part of the VO.

Complete example
----------------

We start with a simple but fairly complete Service provider configuration::

    from saml2 import BINDING_HTTP_REDIRECT

    CONFIG = {
        "entityid" : "http://example.com/sp/metadata.xml",
        "service": {
            "sp":{
                "name" : "Example SP",
                "endpoints":{
                    "assertion_consumer_service": ["http://example.com/sp"],
                    "single_logout_service" : [("http://example.com/sp/slo",
                                                BINDING_HTTP_REDIRECT)],
                },
            }
        },
        "key_file" : "./mykey.pem",
        "cert_file" : "./mycert.pem",
        "xmlsec_binary" : "/usr/local/bin/xmlsec1",
        "attribute_map_dir": "./attributemaps",
        "metadata": {
            "local": ["idp.xml"]
        }
        "organization": {
            "display_name":["Example identities"]
        }
        "contact_person": [{
            "givenname": "Roland",
            "surname": "Hedberg",
            "phone": "+46 90510",
            "mail": "roland@example.com",
            "type": "technical",
            }]
    }

This is the typical setup for a SP.
A metadata file to load is *always* needed, but it can of course be
containing anything from 1 up to many entity descriptions.

------

A slightly more complex configuration::

    from saml2 import BINDING_HTTP_REDIRECT

    CONFIG = {
        "entityid" : "http://sp.example.com/metadata.xml",
        "service": {
            "sp":{
                "name" : "Example SP",
                "endpoints":{
                    "assertion_consumer_service": ["http://sp.example.com/"],
                    "single_logout_service" : [("http://sp.example.com/slo",
                                   BINDING_HTTP_REDIRECT)],
                },
                "subject_data": ("memcached", "localhost:12121"),
                "virtual_organization" : {
                    "urn:mace:example.com:it:tek":{
                        "nameid_format" : "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
                        "common_identifier": "eduPersonPrincipalName",
                    }
                },
            }
        },
        "key_file" : "./mykey.pem",
        "cert_file" : "./mycert.pem",
        "xmlsec_binary" : "/usr/local/bin/xmlsec1",
        "metadata" : { 
            "local": ["example.xml"],
            "remote": [{ 
                "url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
                "cert":"kalmar2.pem"}]
        },
        "attribute_maps" : "attributemaps",
        "organization": {
            "display_name":["Example identities"]
        }
        "contact_person": [{
            "givenname": "Roland",
            "surname": "Hedberg",
            "phone": "+46 90510",
            "mail": "roland@example.com",
            "type": "technical",
            }]
    }
    
Uses metadata files, both local and remote, and will talk to whatever 
IdP that appears in any of the metadata files.