Skip to content

Commit 8518924

Browse files
Merge pull request #803 from sebulibah/documentation
Improve PySAML2 documentation - Add undocumented configuration options
2 parents 3cedd0b + 6b25732 commit 8518924

File tree

1 file changed

+298
-6
lines changed

1 file changed

+298
-6
lines changed

Diff for: docs/howto/config.rst

+298-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.. _howto_config:
22

3-
Configuration of pySAML2 entities
3+
Configuration of PySAML2 entities
44
=================================
55

6-
Whether you plan to run a pySAML2 Service Provider, Identity Provider or an
6+
Whether you plan to run a PySAML2 Service Provider, Identity Provider or an
77
attribute authority, you have to configure it. The format of the configuration
88
file is the same regardless of which type of service you plan to run.
99
What differs are some of the directives.
@@ -51,7 +51,7 @@ The basic structure of the configuration file is therefore like this::
5151
}
5252

5353
.. note:: You can build the metadata file for your services directly from the
54-
configuration. The make_metadata.py script in the pySAML2 tools directory
54+
configuration. The make_metadata.py script in the PySAML2 tools directory
5555
will do that for you.
5656

5757
Configuration directives
@@ -101,7 +101,7 @@ Example::
101101
},
102102
},
103103

104-
The exapmle configuration above will enable DEBUG logging to stdout.
104+
The example configuration above will enable DEBUG logging to stdout.
105105

106106

107107
debug
@@ -247,6 +247,33 @@ The globally unique identifier of the entity.
247247
.. note:: It is recommended that the entityid should point to a real
248248
webpage where the metadata for the entity can be found.
249249

250+
name
251+
^^^^
252+
253+
A string value that sets the name of the PySAML2 entity.
254+
255+
Example::
256+
257+
"name": "Example IdP"
258+
259+
description
260+
^^^^^^^^^^^
261+
262+
A string value that sets the description of the PySAML2 entity.
263+
264+
Example::
265+
266+
"description": "My IdP",
267+
268+
verify_ssl_cert
269+
^^^^^^^^^^^^^^^
270+
271+
Specifies if the SSL certificates should be verified. Can be ``True`` or ``False``.
272+
The default configuration is ``False``.
273+
274+
Example::
275+
276+
"verify_ssl_cert": True
250277

251278
key_file
252279
^^^^^^^^
@@ -269,6 +296,21 @@ Example::
269296
This is the public part of the service private/public key pair.
270297
*cert_file* must be a PEM formatted file with a single certificate.
271298

299+
tmp_cert_file
300+
^^^^^^^^^^^^^
301+
302+
Example::
303+
"tmp_cert_file": "tmp_cert.pem"
304+
305+
*tmp_cert_file* is a PEM formatted certificate file
306+
307+
tmp_key_file
308+
^^^^^^^^^^^^
309+
310+
Example::
311+
"tmp_key_file": "tmp_key.pem"
312+
313+
*tmp_key_file* is a PEM formatted key file.
272314

273315
encryption_keypairs
274316
^^^^^^^^^^^^^^^^^^^
@@ -283,6 +325,27 @@ Indicates which certificates will be used for encryption capabilities::
283325
},
284326
],
285327

328+
generate_cert_info
329+
^^^^^^^^^^^^^^^^^^
330+
331+
Specifies if information about the certificate should be generated.
332+
A boolean value can be ``True`` or ``False``.
333+
334+
Example::
335+
336+
"generate_cert_info": False
337+
338+
339+
ca_certs
340+
^^^^^^^^
341+
342+
This is the path to a file containing root CA certificates for SSL server certificate validation.
343+
344+
Example::
345+
346+
"ca_certs": full_path("cacerts.txt"),
347+
348+
286349
metadata
287350
^^^^^^^^
288351

@@ -450,7 +513,7 @@ difference you are prepared to accept.
450513
Hence your server may accept a statement that in fact is too old.
451514

452515
allow_unknown_attributes
453-
""""""""""""""""""""""""
516+
^^^^^^^^^^^^^^^^^^^^^^^^
454517

455518
Indicates that attributes that are not recognized (they are not configured in
456519
attribute-mapping), will not be discarded.
@@ -466,6 +529,28 @@ Example::
466529

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

532+
xmlsec_path
533+
^^^^^^^^^^^
534+
535+
This option is used to define non-system paths where the xmlsec1 binary can be located.
536+
It can be used when the xmlsec_binary option is not defined.
537+
538+
Example::
539+
540+
"xmlsec_path": ["/usr/local/bin", "/opt/local/bin"],
541+
542+
OR::
543+
544+
from saml2.sigver import get_xmlsec_binary
545+
546+
if get_xmlsec_binary:
547+
xmlsec_path = get_xmlsec_binary(["/opt/local/bin","/usr/local/bin"])
548+
else:
549+
xmlsec_path = '/usr/bin/xmlsec1'
550+
551+
"xmlsec_binary": xmlsec_path,
552+
553+
469554
delete_tmpfiles
470555
^^^^^^^^^^^^^^^
471556

@@ -487,6 +572,76 @@ How many *hours* this configuration is expected to be accurate.::
487572
This, of course, is only used by *make_metadata.py*.
488573
The server will not stop working when this amount of time has elapsed :-).
489574

575+
576+
metadata_key_usage
577+
^^^^^^^^^^^^^^^^^^^
578+
579+
This specifies the purpose of the entity's cryptographic keys used to sign data.
580+
If this option is not configured it will default to ``"both"``.
581+
582+
The possible options for this configuration are ``both``, ``signing``, ``encryption``.
583+
584+
If metadata_key_usage is set to ``"signing"`` or ``"both"``, and a cert_file is provided
585+
the value of use in the KeyDescriptor element will be set to ``"signing"``.
586+
587+
If metadata_key_usage is set to ``"both"`` or ``"encryption"`` and a enc_cert is provided
588+
the value of ``"use"`` in the KeyDescriptor will be set to ``"encryption"``.
589+
590+
Example::
591+
592+
"metadata_key_usage" : "both",
593+
594+
595+
secret
596+
^^^^^^
597+
598+
A string value that is used in the generation of the RelayState.
599+
600+
Example::
601+
602+
"secret": "0123456789",
603+
604+
crypto_backend
605+
^^^^^^^^^^^^^^
606+
Defines the crypto backend used for signing and encryption. The default is ``xmlsec1``.
607+
The options are ``xmlsec1`` and ``XMLSecurity``.
608+
609+
If set to "XMLSecurity", the crypto backend will be pyXMLSecurity.
610+
611+
Example::
612+
613+
"crypto_backend": "xmlsec1",
614+
615+
verify_encrypt_advice
616+
^^^^^^^^^^^^^^^^^^^^^
617+
618+
Specifies if the encrypted assertions in the advice element should be verified.
619+
Can be ``True`` or ``False``.
620+
621+
Example::
622+
623+
def verify_encrypt_cert(cert_str):
624+
osw = OpenSSLWrapper()
625+
ca_cert_str = osw.read_str_from_file(full_path("root_cert/localhost.ca.crt"))
626+
valid, mess = osw.verify(ca_cert_str, cert_str)
627+
return valid
628+
629+
::
630+
631+
"verify_encrypt_cert_advice": verify_encrypt_cert,
632+
633+
634+
verify_encrypt_cert_assertion
635+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
636+
637+
Specifies if the encrypted assertions should be verified.
638+
Can be ``True`` or ``False``.
639+
640+
Example::
641+
642+
"verify_encrypt_cert_assertion": verify_encrypt_cert
643+
644+
490645
Specific directives
491646
-------------------
492647

@@ -509,6 +664,29 @@ sign_response
509664
Specifies if the IdP should sign the authentication response or not. Can be
510665
True or False. Default is False.
511666

667+
encrypt_assertion
668+
"""""""""""""""""
669+
670+
Specifies if the IdP should encrypt the assertions. Can be ``True`` or ``False``.
671+
Default is ``False``.
672+
673+
encrypted_advice_attributes
674+
"""""""""""""""""""""""""""
675+
Specifies if assertions in the advice element should be encrypted.
676+
Can be ``True`` or ``False``. Default is ``False``.
677+
678+
encrypt_assertion_self_contained
679+
""""""""""""""""""""""""""""""""
680+
681+
Specifies if all encrypted assertions should have all namespaces self contained.
682+
Can be ``True`` or ``False``. Default is ``True``.
683+
684+
want_authn_requests_signed
685+
""""""""""""""""""""""""""
686+
687+
Indicates that the AuthnRequest received by this IdP should be signed. Can be ``True`` or ``False``.
688+
The default value is ``False``.
689+
512690
want_authn_requests_only_with_valid_cert
513691
""""""""""""""""""""""""""""""""""""""""
514692

@@ -608,6 +786,79 @@ regular expressions.::
608786

609787
Here only mail addresses that end with ".umu.se" will be returned.
610788

789+
scope
790+
"""""
791+
792+
A list of string values that will be used to set the ``<Scope>`` element
793+
The default value of regexp is ``False``.
794+
795+
Example::
796+
797+
"scope": ["example.org", "example.com"],
798+
799+
800+
ui_info
801+
""""""""
802+
803+
This determines what information to display about an entity by
804+
configuring its mdui:UIInfo element. The configurable options include;
805+
806+
*privacy_statement_url*
807+
The URL to information about the privacy practices of the entity.
808+
*information_url*
809+
Which URL contains localized information about the entity.
810+
*logo*
811+
The logo image for the entity. The value is a dictionary with keys
812+
height, width and text.
813+
*display_name*
814+
The localized name for the entity.
815+
*description*
816+
The localized description of the entity. The value is a dictionary with keys
817+
text and lang.
818+
*keywords*
819+
The localized search keywords for the entity. The value is a dictionary with keys
820+
lang and text.
821+
822+
Example::
823+
824+
"ui_info": {
825+
"privacy_statement_url": "http://example.com/saml2/privacyStatement.html",
826+
"information_url": "http://example.com/saml2/info.html",
827+
"logo": {
828+
"height": "40",
829+
"width" : "30",
830+
"text": "http://example.com/logo.jpg"
831+
},
832+
"display_name": "Example Co.",
833+
"description" : {"text":"Exempel Bolag","lang":"se"},
834+
"keywords": {"lang":"en", "text":["foo", "bar"]}
835+
}
836+
837+
838+
name_qualifier
839+
""""""""""""""
840+
841+
A string value that sets the ``NameQualifier`` attribute of the ``<NameIdentifier>`` element.
842+
843+
Example::
844+
845+
"name_qualifier": "http://authentic.example.com/saml/metadata",
846+
847+
848+
session_storage
849+
"""""""""""""""
850+
851+
Example::
852+
853+
"session_storage": ("mongodb", "session")
854+
855+
domain
856+
""""""
857+
858+
Example::
859+
860+
"domain": "umu.se",
861+
611862
sp
612863
^^
613864

@@ -929,6 +1180,47 @@ Example::
9291180
}
9301181
}
9311182

1183+
discovery_response
1184+
""""""""""""""""""
1185+
1186+
This configuration allows the SP to include one or more Discovery Response Endpoints.
1187+
The discovery_response can be the just the URL::
1188+
1189+
"discovery_response":["http://example.com/sp/ds"],
1190+
1191+
or it can be a 2 tuple of the URL+Binding::
1192+
1193+
from saml2.extension.idpdisc import BINDING_DISCO
1194+
1195+
"discovery_response": [("http://example.com/sp/ds", BINDING_DISCO)]
1196+
1197+
ecp
1198+
"""
1199+
1200+
This configuration option takes a dictionary with the ecp client IP address as the
1201+
key and the entity ID as the value.
1202+
1203+
Example::
1204+
1205+
"ecp": {
1206+
"203.0.113.254": "http://example.com/idp",
1207+
}
1208+
1209+
requested_attribute_name_format
1210+
"""""""""""""""""""""""""""""""
1211+
1212+
This sets the NameFormat attribute in the ``<RequestedAttribute>`` element.
1213+
The name formats are defined in saml2.saml.py. If not configured the default is ``NAME_FORMAT_URI``
1214+
which corresponds to ``urn:oasis:names:tc:SAML:2.0:attrname-format:uri``.
1215+
1216+
Example::
1217+
1218+
from saml2.saml import NAME_FORMAT_BASIC
1219+
1220+
::
1221+
1222+
"requested_attribute_name_format": NAME_FORMAT_BASIC
1223+
9321224

9331225
idp/aa/sp
9341226
^^^^^^^^^
@@ -1211,7 +1503,7 @@ Entity Categories
12111503

12121504
Entity categories and their attributes are defined in
12131505
src/saml2/entity_category/<registrar-of-entity-category>.py.
1214-
We can configure Entity Categories in pysaml2 in two ways:
1506+
We can configure Entity Categories in PySAML2 in two ways:
12151507

12161508
1. Using the configuration options *entity_category_support* or
12171509
*entity_category*, to generate the appropriate EntityAttribute metadata

0 commit comments

Comments
 (0)