Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 71e65e2

Browse files
committed
docs updated
1 parent 803b465 commit 71e65e2

File tree

2 files changed

+24
-38
lines changed

2 files changed

+24
-38
lines changed

docs/configuration.rst

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ Now include ``djangosaml2idp`` in your project by adding it in the url config::
2020
...
2121
]
2222

23+
Run the migrations for the app.
24+
2325
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::
2426

25-
...
2627
import saml2
2728
from saml2.saml import NAMEID_FORMAT_EMAILADDRESS, NAMEID_FORMAT_UNSPECIFIED
2829
from saml2.sigver import get_xmlsec_binary
@@ -41,19 +42,21 @@ In your Django settings, configure your IdP. Configuration follows the `PySAML2
4142
'name': 'Django localhost IdP',
4243
'endpoints': {
4344
'single_sign_on_service': [
44-
('%s/sso/post' % BASE_URL, saml2.BINDING_HTTP_POST),
45-
('%s/sso/redirect' % BASE_URL, saml2.BINDING_HTTP_REDIRECT),
45+
('http://localhost:9000/idp/sso/post/', saml2.BINDING_HTTP_POST),
46+
('http://localhost:9000/idp/sso/redirect/', saml2.BINDING_HTTP_REDIRECT),
47+
],
48+
"single_logout_service": [
49+
("http://localhost:9000/idp/slo/post/", saml2.BINDING_HTTP_POST),
50+
("http://localhost:9000/idp/slo/redirect/", saml2.BINDING_HTTP_REDIRECT)
4651
],
4752
},
4853
'name_id_format': [NAMEID_FORMAT_EMAILADDRESS, NAMEID_FORMAT_UNSPECIFIED],
4954
'sign_response': True,
5055
'sign_assertion': True,
56+
'want_authn_requests_signed': True,
5157
},
5258
},
5359

54-
'metadata': {
55-
'local': [os.path.join(os.path.join(os.path.join(BASE_DIR, 'idp'), 'saml2_config'), 'sp_metadata.xml')],
56-
},
5760
# Signing
5861
'key_file': BASE_DIR + '/certificates/private.key',
5962
'cert_file': BASE_DIR + '/certificates/public.cert',
@@ -68,36 +71,12 @@ In your Django settings, configure your IdP. Configuration follows the `PySAML2
6871

6972
Notice the configuration requires a private key and public certificate to be available on the filesystem in order to sign and encrypt messages.
7073

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.
7176

72-
You also have to define a mapping for each SP you talk to. An example SP config::
73-
74-
...
75-
SAML_IDP_SPCONFIG = {
76-
'http://localhost:8000/saml2/metadata/': {
77-
'processor': 'djangosaml2idp.processors.BaseProcessor',
78-
'nameid_field': 'staffID'
79-
'sign_response': False,
80-
'sign_assertion': False,
81-
'attribute_mapping': {
82-
# DJANGO: SAML
83-
'email': 'email',
84-
'first_name': 'first_name',
85-
'last_name': 'last_name',
86-
'is_staff': 'is_staff',
87-
'is_superuser': 'is_superuser',
88-
}
89-
}
90-
}
91-
92-
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.
10180

10281
Further optional configuration options
10382
======================================
@@ -112,4 +91,8 @@ Use this metadata xml to configure your SP. Place the metadata xml from that SP
11291

11392
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.
11493
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.:
96+
97+
SAML_AUTHN_SIGN_ALG = saml2.xmldsig.SIG_RSA_SHA256
98+
SAML_AUTHN_DIGEST_ALG = saml2.xmldsig.DIGEST_SHA256

docs/index.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ djangosaml2idp
3333
:target: https://www.apache.org/licenses/LICENSE-2.0
3434
:alt: Apache 2.0 License
3535

36+
.. image:: https://codecov.io/gh/ota-insight/djangosaml2idp/branch/master/graph/badge.svg
37+
:scale: 100%
38+
:target: https://codecov.io/gh/ota-insight/djangosaml2idp
39+
:alt: Code coverage
40+
3641

3742
djangosaml2idp implements the Identity Provider side of the SAML2 protocol for Django.
3843
It builds on top of `PySAML2 <https://github.com/IdentityPython/pysaml2>`_, and is production-ready.
3944

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-
4245
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.
4346

4447

0 commit comments

Comments
 (0)