Skip to content

Commit a926165

Browse files
committed
Merge branch 'master' of github.com:rohe/pysaml2
2 parents 9a75469 + 9617003 commit a926165

File tree

5 files changed

+47
-32
lines changed

5 files changed

+47
-32
lines changed

src/saml2/assertion.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,8 @@ def post_entity_categories(maps, **kwargs):
273273
required = []
274274

275275
if kwargs["mds"]:
276-
try:
276+
if "sp_entity_id" in kwargs:
277277
ecs = kwargs["mds"].entity_categories(kwargs["sp_entity_id"])
278-
except KeyError:
279-
for ec_map in maps:
280-
for attr in ec_map[""]:
281-
restrictions[attr] = None
282-
else:
283278
for ec_map in maps:
284279
for key, (atlist, only_required) in ec_map.items():
285280
if key == "": # always released
@@ -305,6 +300,10 @@ def post_entity_categories(maps, **kwargs):
305300

306301
for attr in attrs:
307302
restrictions[attr] = None
303+
else:
304+
for ec_map in maps:
305+
for attr in ec_map[""]:
306+
restrictions[attr] = None
308307

309308
return restrictions
310309

src/saml2/discovery.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from six.moves.urllib.parse import urlencode, parse_qs, urlparse
1+
from future.backports.urllib.parse import parse_qs
2+
from future.backports.urllib.parse import urlencode
3+
from future.backports.urllib.parse import urlparse
4+
25
from saml2.entity import Entity
36
from saml2.response import VerificationError
47

@@ -9,7 +12,8 @@
912

1013
class DiscoveryServer(Entity):
1114
def __init__(self, config=None, config_file=""):
12-
Entity.__init__(self, "disco", config, config_file)
15+
if config or config_file:
16+
Entity.__init__(self, "disco", config, config_file)
1317

1418
def parse_discovery_service_request(self, url="", query=""):
1519
if url:
@@ -22,7 +26,8 @@ def parse_discovery_service_request(self, url="", query=""):
2226

2327
# verify
2428

25-
for key in ["isPassive", "return", "returnIDParam", "policy"]:
29+
for key in ["isPassive", "return", "returnIDParam", "policy",
30+
'entityID']:
2631
try:
2732
assert len(dsr[key]) == 1
2833
dsr[key] = dsr[key][0]

src/saml2/mdstore.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def any(self, typ, service, binding=None):
269269
"""
270270
Return any entity that matches the specification
271271
272-
:param typ:
272+
:param typ: Type of entity
273273
:param service:
274274
:param binding:
275275
:return:
@@ -282,6 +282,37 @@ def any(self, typ, service, binding=None):
282282

283283
return res
284284

285+
def any2(self, typ, service, binding=None):
286+
"""
287+
288+
:param type:
289+
:param service:
290+
:param binding:
291+
:return:
292+
"""
293+
res = {}
294+
for entid, item in self.items():
295+
hit = False
296+
try:
297+
descr = item['{}sso_descriptor'.format(typ)]
298+
except KeyError:
299+
continue
300+
else:
301+
for desc in descr:
302+
try:
303+
srvs = desc[service]
304+
except KeyError:
305+
continue
306+
else:
307+
for srv in srvs:
308+
if srv['binding'] == binding:
309+
res[entid] = item
310+
hit = True
311+
break
312+
if hit:
313+
break
314+
return res
315+
285316
def bindings(self, entity_id, typ, service):
286317
"""
287318
Get me all the bindings that are registered for a service entity
@@ -305,7 +336,7 @@ def attribute_requirement(self, entity_id, index=None):
305336
raise NotImplementedError
306337

307338
def dumps(self):
308-
return json.dumps(self.items(), indent=2)
339+
return json.dumps(list(self.items()), indent=2)
309340

310341
def with_descriptor(self, descriptor):
311342
'''

tests/test_37_entity_categories.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
from contextlib import closing
2-
from saml2 import saml, sigver
3-
from saml2 import md
2+
from saml2 import sigver
43
from saml2 import config
54
from saml2.assertion import Policy
65
from saml2.attribute_converter import ac_factory
7-
from saml2.extension import mdui
8-
from saml2.extension import idpdisc
9-
from saml2.extension import dri
10-
from saml2.extension import mdattr
11-
from saml2.extension import ui
126
from pathutils import full_path
137
from saml2.mdstore import MetadataStore
148
from saml2.server import Server
15-
from saml2 import xmldsig
16-
from saml2 import xmlenc
179

1810

1911
ATTRCONV = ac_factory(full_path("attributemaps"))

tools/verify_metadata.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@
22

33
import argparse
44

5-
from saml2 import saml
6-
from saml2 import md
7-
from saml2 import xmldsig
8-
from saml2 import xmlenc
9-
105
from saml2.attribute_converter import ac_factory
116
from saml2.httpbase import HTTPBase
12-
from saml2.extension import dri
13-
from saml2.extension import idpdisc
14-
from saml2.extension import mdattr
15-
from saml2.extension import mdrpi
16-
from saml2.extension import mdui
17-
from saml2.extension import shibmd
18-
from saml2.extension import ui
197

208
from saml2.sigver import _get_xmlsec_cryptobackend
219
from saml2.sigver import SecurityContext

0 commit comments

Comments
 (0)