You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 26, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: docs/configuration.rst
+19-36Lines changed: 19 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,10 @@ Now include ``djangosaml2idp`` in your project by adding it in the url config::
20
20
...
21
21
]
22
22
23
+
Run the migrations for the app.
24
+
23
25
In your Django settings, configure your IdP. Configuration follows the `PySAML2 configuration <https://github.com/IdentityPython/pysaml2/blob/master/docs/howto/config.rst>`_. The IdP from the example project looks like this::
24
26
25
-
...
26
27
import saml2
27
28
from saml2.saml import NAMEID_FORMAT_EMAILADDRESS, NAMEID_FORMAT_UNSPECIFIED
28
29
from saml2.sigver import get_xmlsec_binary
@@ -41,19 +42,21 @@ In your Django settings, configure your IdP. Configuration follows the `PySAML2
@@ -68,36 +71,12 @@ In your Django settings, configure your IdP. Configuration follows the `PySAML2
68
71
69
72
Notice the configuration requires a private key and public certificate to be available on the filesystem in order to sign and encrypt messages.
70
73
74
+
Next the Service Providers and their configuration need to be added, this is done via the Django admin interface. Add an entry for each SP which speaks to thie IdP.
75
+
Add a copy of the local metadata xml, or set a remote metadata url. Add an attribute mapping for user attributes to SAML fields or leave the default mapping which will be prefilled.
71
76
72
-
You also have to define a mapping for each SP you talk to. An example SP config::
Please note that the only required field for each SP is the Entity ID. ``attribute_mapping`` will default to ``{'username': 'username'}``.
93
-
If you would like to not send any attributes to the SP, set ``attribute_mapping`` to an empty dict (``{}``).
94
-
95
-
If you want to override ``sign_assertion`` and/or ``sign_response`` for individual SPs, you can do so in ``SAML_IDP_SPCONFIG``, as seen above. If unset, these will default to the values set in ``SAML_IDP_CONFIG``.
96
-
97
-
98
-
The last step is configuring metadata.
99
-
Download a copy of the IdP's metadata from <YOUR_SERVER_URL>/idp/metadata (assuming that's how you set up your urls.py). Use it to configure your SPs as required by them.
100
-
Obtain a copy of the metadata for each of your SPs, and upload them where you indicated in ``SAML_IDP_CONFIG['metadata]``
77
+
Several attributes can be overriden per SP. If they aren't overridden explicitly, they will use the 'global' settings which can be configured for your Django installation.
78
+
If those aren't set, some defaults will be used, as indicated in the admin when you configre a SP.
79
+
The resulting configuration of a SP, with merged settings of its own and the instance settings and defaults, is shown in the admin as a summary.
101
80
102
81
Further optional configuration options
103
82
======================================
@@ -112,4 +91,8 @@ Use this metadata xml to configure your SP. Place the metadata xml from that SP
112
91
113
92
Without custom setting, users will be identified by the ``USERNAME_FIELD`` property on the user Model you use. By Django defaults this will be the username.
114
93
You can customize which field is used for the identifier by adding ``SAML_IDP_DJANGO_USERNAME_FIELD`` to your settings with as value the attribute to use on your user instance.
115
-
You can also override this per SP by setting ``nameid_field`` in the SP config, as seen in the sample ``SAML_IDP_SPCONFIG`` above.
94
+
95
+
Other settings you can set as defaults to be used if not overriden by an SP are `SAML_AUTHN_SIGN_ALG`, `SAML_AUTHN_DIGEST_ALG`, and `SAML_ENCRYPT_AUTHN_RESPONSE`. They can be set if desired in the django settings, in which case they will be used for all ServiceProviders configuration on this instance if they don't override it. E.g.:
djangosaml2idp implements the Identity Provider side of the SAML2 protocol for Django.
38
43
It builds on top of `PySAML2 <https://github.com/IdentityPython/pysaml2>`_, and is production-ready.
39
44
40
-
Package version 0.3.3 was the last Python 2 / Django 1.8-1.11 compatible release. Versions starting from 0.4.0 are for Python 3 and Django 2.x.
41
-
42
45
Any contributions, feature requests, proposals, ideas ... are welcome! See the `CONTRIBUTING document <https://github.com/OTA-Insight/djangosaml2idp/blob/master/CONTRIBUTING.md>`_ for some info.
0 commit comments