Skip to content

Commit 7107413

Browse files
committed
selected_idps variable now get the only available idp instead of None
otherwise next logger message will print None Better exception handling on missing IDP configuration. Better LOG message if only one idp is available new file: djangosaml2/exceptions.py modified: djangosaml2/views.py
1 parent 8253032 commit 7107413

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

djangosaml2/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class IdPConfigurationMissing(Exception):
2+
pass

djangosaml2/views.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
from djangosaml2.cache import IdentityCache, OutstandingQueriesCache
5151
from djangosaml2.cache import StateCache
52+
from djangosaml2.exceptions import IdPConfigurationMissing
5253
from djangosaml2.conf import get_config
5354
from djangosaml2.overrides import Saml2Client
5455
from djangosaml2.signals import post_authenticated
@@ -144,7 +145,13 @@ def login(request,
144145
'available_idps': idps.items(),
145146
'came_from': came_from,
146147
})
147-
148+
else:
149+
# is the first one, otherwise next logger message will print None
150+
if not idps:
151+
raise IdPConfigurationMissing(('IdP configuration is missing or '
152+
'its metadata is expired.'))
153+
selected_idp = list(idps.keys())[0]
154+
148155
# choose a binding to try first
149156
sign_requests = getattr(conf, '_sp_authn_requests_signed', False)
150157
binding = BINDING_HTTP_POST if sign_requests else BINDING_HTTP_REDIRECT

0 commit comments

Comments
 (0)