3
Configuration of pySAML2 entities
4
=================================
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.
14
The basic structure of the configuration file is therefor like this::
16
from saml2 import BINDING_HTTP_REDIRECT
19
"entityid" : "http://saml.example.com:saml/idp.xml",
20
"name" : "Rolands IdP",
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)]
34
"key_file" : "my.key",
35
"cert_file" : "ca.pem",
36
"xmlsec_binary" : "/usr/local/bin/xmlsec1",
38
"local": ["edugain.xml"],
40
"attribute_map_dir" : "attributemaps",
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
48
Configuration directives
49
::::::::::::::::::::::::
63
"attribute_map_dir": "attribute-maps"
65
Points to a directory which has the attribute maps in Python modules.
66
A typical map file will looks like this::
69
"identifier": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic",
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',
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',
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.
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.
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.
104
cert_file: "cert.pem"
106
This is the public part of the service private/public key pair.
107
*cert_file* must be a PEM formatted certificate chain file.
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**
120
"givenname": "Derek",
122
"company": "Example Co.",
123
"mail": ["jeter@example.com"],
127
"surname": "Girardi",
128
"company": "Example Co.",
129
"mail": "girardi@example.com",
130
"type": "administrative",
140
Whether debug information should be sent to the log file.
147
entityid: "http://saml.example.com/sp"
149
The globally unique identifier of the entity.
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.
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.
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.::
173
"metadata.xml", "vo_metadata.xml"
177
"url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
178
"cert":"kalmar2.cert"
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.
191
Only used by *make_metadata.py*.
192
Where you describe the organization responsible for the service.::
195
"name": [("Example Company","en"), ("Exempel AB","se")],
196
"display_name": ["Exempel AB"],
197
"url": [("http://example.com","en"),("http://exempel.se","se")],
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).
208
Which services the server will provide, those are combinations of "idp","sp"
210
So if a server is a Service Provider (SP) then the configuration
211
could look something like this::
215
"name" : "Rolands SP",
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')],
221
"required_attributes": ["surname", "givenname", "edupersonaffiliation"],
222
"optional_attributes": ["title"],
224
"urn:mace:umu.se:saml:roland:idp": None,
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
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.
240
.. note:: This will indiscriminately effect all time comparisons.
241
Hence your server my accept a statement that in fact is to old.
246
Presently xmlsec1 binaries are used for all the signing and encryption stuff.
247
This option defines where the binary is situated.
251
"xmlsec_binary": "/usr/local/bin/xmlsec1",
256
How many *hours* this configuration is expected to be accurate.::
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 :-).
266
Directives that are specific to a certain type of service.
271
Directives that are specific to an IdP or AA service instance
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::
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"
292
"urn:mace:example.com:saml:roland:sp": {
293
"lifetime": {"minutes": 5},
294
"attribute_restrictions":{
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
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.
317
Which name-form that should be used when sending assertions.
319
If restrictions on values are deemed necessary those are represented by
320
regular expressions.::
325
"urn:mace:umu.se:saml:roland:sp": {
326
"lifetime": {"minutes": 5},
327
"attribute_restrictions":{
328
"mail": [".*\.umu\.se$"],
335
Here only mail addresses that ends with ".umu.se" will be returned.
340
Directives specific to SP instances
342
authn_requests_signed
343
"""""""""""""""""""""
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.
348
This set the AuthnRequestsSigned attribute of the SPSSODescriptor node.
349
of the metadata so the IdP will know this SP preference.
351
Valid values are "true" or "false". Default value is "false".
357
"authn_assertions_signed": "true",
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::
373
"idp": ["urn:mace:umu.se:saml:roland:idp"],
377
In this case the SP has only one IdP it can use.
379
If all IdPs present in the metadata loaded this directive must be left out.
384
Attributes that this SP would like to receive from IdPs.
390
"optional_attributes": ["title"],
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
401
Attributes that this SP demands to receive from IdPs.
407
"required_attributes": ["surname", "givenName", "mail"],
411
Again as for *optional_attributes* the names given are expected to be
412
the user friendly names.
414
want_assertions_signed
415
""""""""""""""""""""""
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.
421
Valid values are "true" or "false". Default value is "true".
427
"want_assertions_signed": "true",
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.
442
Where the endpoints for the services provided are.
443
This directive has as value a dictionary with one of the following keys:
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)
454
The values per service is a list of tuples containing endpoint and binding
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)]
470
logout_requests_signed
471
""""""""""""""""""""""
473
Indicates if this entity will sign the Logout Requests originated from it.
475
This can be overriden by application code for a specific call.
477
Valid values are "true" or "false". Default value is "false"
483
"logout_requests_signed": "true",
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.
499
"subject_data": "./idp.subject.db",
501
or if you want to use for instance memcache::
503
"subject_data": ("memcached", "localhost:12121"),
505
*shelve* and *memcached* are the only database types that are presently
512
Gives information about common identifiers for virtual_organizations::
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",
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.
529
We start with a simple but fairly complete Service provider configuration::
531
from saml2 import BINDING_HTTP_REDIRECT
534
"entityid" : "http://example.com/sp/metadata.xml",
537
"name" : "Example SP",
539
"assertion_consumer_service": ["http://example.com/sp"],
540
"single_logout_service" : [("http://example.com/sp/slo",
541
BINDING_HTTP_REDIRECT)],
545
"key_file" : "./mykey.pem",
546
"cert_file" : "./mycert.pem",
547
"xmlsec_binary" : "/usr/local/bin/xmlsec1",
548
"attribute_map_dir": "./attributemaps",
553
"display_name":["Example identities"]
556
"givenname": "Roland",
557
"surname": "Hedberg",
558
"phone": "+46 90510",
559
"mail": "roland@example.com",
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.
570
A slightly more complex configuration::
572
from saml2 import BINDING_HTTP_REDIRECT
575
"entityid" : "http://sp.example.com/metadata.xml",
578
"name" : "Example SP",
580
"assertion_consumer_service": ["http://sp.example.com/"],
581
"single_logout_service" : [("http://sp.example.com/slo",
582
BINDING_HTTP_REDIRECT)],
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",
593
"key_file" : "./mykey.pem",
594
"cert_file" : "./mycert.pem",
595
"xmlsec_binary" : "/usr/local/bin/xmlsec1",
597
"local": ["example.xml"],
599
"url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
600
"cert":"kalmar2.pem"}]
602
"attribute_maps" : "attributemaps",
604
"display_name":["Example identities"]
607
"givenname": "Roland",
608
"surname": "Hedberg",
609
"phone": "+46 90510",
610
"mail": "roland@example.com",
615
Uses metadata files, both local and remote, and will talk to whatever
616
IdP that appears in any of the metadata files.