Skip to content

Commit 5c59f6b

Browse files
authored
Merge pull request #150 from peppelinux/selected_idps
selected_idps variable now get the only available idp instead of None
2 parents 464d6ef + 7107413 commit 5c59f6b

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
@@ -57,6 +57,7 @@
5757

5858
from djangosaml2.cache import IdentityCache, OutstandingQueriesCache
5959
from djangosaml2.cache import StateCache
60+
from djangosaml2.exceptions import IdPConfigurationMissing
6061
from djangosaml2.conf import get_config
6162
from djangosaml2.overrides import Saml2Client
6263
from djangosaml2.signals import post_authenticated
@@ -159,7 +160,13 @@ def login(request,
159160
'available_idps': idps.items(),
160161
'came_from': came_from,
161162
})
162-
163+
else:
164+
# is the first one, otherwise next logger message will print None
165+
if not idps:
166+
raise IdPConfigurationMissing(('IdP configuration is missing or '
167+
'its metadata is expired.'))
168+
selected_idp = list(idps.keys())[0]
169+
163170
# choose a binding to try first
164171
sign_requests = getattr(conf, '_sp_authn_requests_signed', False)
165172
binding = BINDING_HTTP_POST if sign_requests else BINDING_HTTP_REDIRECT

0 commit comments

Comments
 (0)