Skip to content

Commit 746131e

Browse files
author
Dan Campbell
committed
Merge branch 'error_views'
2 parents 97e78f6 + b9e17af commit 746131e

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed
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)