Skip to content

Commit c9ac2e7

Browse files
peppelinuxsur.la.route
andauthored
Documentation (#301)
* Update views.py (#297) changed from error to debug * Unsupported Binding exception in SLO There's the possibility that an IdP doesn't support the SLO, added an exception handling as a workaround for this. Now we have in the log something like: ```` Unsupported binding: None (https://172.17.0.1:10000/Saml2IDP/metadata) Error Handled - SLO - unsupported binding by IDP: None Traceback (most recent call last): File "~/DEV/IdentityPython/env/lib/python3.8/site-packages/djangosaml2/views.py", line 601, in get result = client.global_logout(subject_id) File "~/DEV/IdentityPython/env/lib/python3.8/site-packages/saml2/client.py", line 210, in global_logout return self.do_logout( File "~/DEV/IdentityPython/env/lib/python3.8/site-packages/djangosaml2/overrides.py", line 25, in do_logout return super().do_logout(*args, **kwargs) File "~/DEV/IdentityPython/env/lib/python3.8/site-packages/saml2/client.py", line 259, in do_logout bindings_slo_supported = self.metadata.single_logout_service( File "~/DEV/IdentityPython/env/lib/python3.8/site-packages/saml2/mdstore.py", line 1236, in single_logout_service return self.service(entity_id, "%s_descriptor" % typ, File "~/DEV/IdentityPython/env/lib/python3.8/site-packages/saml2/mdstore.py", line 1147, in service raise UnsupportedBinding(binding) saml2.s_utils.UnsupportedBinding: None ```` * v1.3.2 * chore: Documentation improvements that fixed #231 and #299 (@tkloda) Co-authored-by: sur.la.route <christopher.pickering@keemail.me>
1 parent aa95de2 commit c9ac2e7

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

docs/source/contents/setup.rst

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,35 @@ Learn more about Django profile models at:
380380
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model
381381

382382

383+
Custom user attributes processing
384+
---------------------------------
385+
383386
Sometimes you need to use special logic to update the user object
384387
depending on the SAML2 attributes and the mapping described above
385388
is simply not enough. For these cases djangosaml2 provides hooks_
386-
that can be overriden with custom functionality. For example::
389+
that can be overriden with custom functionality.
390+
391+
First of all reference the modified Saml2Backend in settings.py file::
392+
393+
394+
AUTHENTICATION_BACKENDS = [
395+
'your_package.authentication.ModifiedSaml2Backend',
396+
]
397+
398+
399+
For example::
400+
401+
from djangosaml2.backends import Saml2Backend
387402

388-
from djangosaml2.backends import Saml2Backend
403+
class ModifiedSaml2Backend(Saml2Backend):
404+
def save_user(self, user, *args, **kwargs):
405+
user.save()
406+
user_group = Group.objects.get(name='Default')
407+
user.groups.add(user_group)
408+
return super().save_user(user, *args, **kwargs)
389409

390-
class MySaml2Backend(Saml2Backend):
391-
def save_user(self, user, *args, **kwargs):
392-
# Add custom logic here
393-
return super().save_user(user, *args, **kwargs)
410+
.. _hooks: https://github.com/identitypython/djangosaml2/blob/master/djangosaml2/backends.py#L181
394411

395-
.. _hooks: https://github.com/knaperek/djangosaml2/blob/master/djangosaml2/backends.py#L181
396412

397413

398414
URLs

0 commit comments

Comments
 (0)