Skip to content

Commit 49b5b4f

Browse files
authored
Merge pull request #39 from ws0w/master
Fix for Issue #37
2 parents 7ec6346 + cf32d34 commit 49b5b4f

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ following code to your app::
415415

416416
from djangosaml2.signals import pre_user_save
417417

418-
def custom_update_user(sender=user, attributes=attributes, user_modified=user_modified)
418+
def custom_update_user(sender=User, instance, attributes, user_modified, **kargs)
419419
...
420420
return True # I modified the user object
421421

djangosaml2/backends.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ def update_user(self, user, attributes, attribute_mapping,
249249
logger.debug('Sending the pre_save signal')
250250
signal_modified = any(
251251
[response for receiver, response
252-
in pre_user_save.send_robust(sender=user,
252+
in pre_user_save.send_robust(sender=user.__class__,
253+
instance=user,
253254
attributes=attributes,
254255
user_modified=user_modified)]
255256
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6+
</head>
7+
<body>
8+
<h1>Authentication Error.</h1>
9+
10+
<h2>Access Denied.</h2>
11+
12+
</body>
13+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6+
</head>
7+
<body>
8+
<h1>Permission Denied.</h1>
9+
10+
</body>
11+
</html>

djangosaml2/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def csrf_exempt(view_func):
4747
from saml2.metadata import entity_descriptor
4848
from saml2.ident import code, decode
4949
from saml2.sigver import MissingKey
50+
from saml2.response import StatusError
5051

5152
from djangosaml2.cache import IdentityCache, OutstandingQueriesCache
5253
from djangosaml2.cache import StateCache
@@ -223,6 +224,9 @@ def assertion_consumer_service(request,
223224
try:
224225
response = client.parse_authn_request_response(xmlstr, BINDING_HTTP_POST,
225226
outstanding_queries)
227+
except StatusError:
228+
return render(request, 'djangosaml2/login_error.html', status=403)
229+
226230
except MissingKey:
227231
logger.error('MissingKey error in ACS')
228232
return HttpResponseForbidden(
@@ -250,7 +254,7 @@ def assertion_consumer_service(request,
250254
create_unknown_user=create_unknown_user)
251255
if user is None:
252256
logger.error('The user is None')
253-
raise PermissionDenied
257+
return render(request, 'djangosaml2/permission_denied.html', status=403)
254258

255259
auth.login(request, user)
256260
_set_subject_id(request.session, session_info['name_id'])

0 commit comments

Comments
 (0)