Skip to content

Commit 480fb88

Browse files
committed
Provide nice error message when IdP configuration is missing.
This fixes issue #70.
1 parent 5fa6b1a commit 480fb88

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

djangosaml2/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
from django.conf import settings
16+
from django.core.exceptions import ImproperlyConfigured
1617
from saml2.s_utils import UnknownSystemEntity
1718

1819

@@ -46,7 +47,10 @@ def get_idp_sso_supported_bindings(idp_entity_id=None, config=None):
4647
# if idp is None, assume only one exists so just use that
4748
if idp_entity_id is None:
4849
# .keys() returns dict_keys in python3.5+
49-
idp_entity_id = list(available_idps(config).keys()).pop()
50+
try:
51+
idp_entity_id = list(available_idps(config).keys())[0]
52+
except IndexError:
53+
raise ImproperlyConfigured("No IdP configured!")
5054
try:
5155
return meta.service(idp_entity_id, 'idpsso_descriptor', 'single_sign_on_service').keys()
5256
except UnknownSystemEntity:

0 commit comments

Comments
 (0)