Skip to content

Commit 44b89e7

Browse files
committed
Improve SOAP modelling and reactive validation
1 parent a51e433 commit 44b89e7

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

shibboleth/slo_view.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from shibboleth.models import ShibSession
33
#SLO (back-channel) / spyne stuff
44
from spyne.model.primitive import Unicode
5-
#from spyne.model import XmlAttribute
5+
from spyne.model import XmlAttribute
6+
from spyne.model.enum import Enum
67
try:
78
from spyne.service import Service
89
except ImportError:
@@ -23,19 +24,29 @@ class Attributes(Unicode.Attributes):
2324
min_occurs = 1
2425

2526

27+
class LogoutRequest(ComplexModel):
28+
__namespace__ = 'urn:mace:shibboleth:2.0:sp:notify'
29+
SessionID = MandatoryUnicode
30+
type = XmlAttribute(Enum("global", "local",
31+
type_name="LogoutNotificationType"))
32+
33+
34+
class LogoutResponse(ComplexModel):
35+
__namespace__ = 'urn:mace:shibboleth:2.0:sp:notify'
36+
OK = OKType
37+
38+
2639
class LogoutNotificationService(Service):
27-
@rpc(MandatoryUnicode, _returns=OKType,
28-
_in_variable_names={'sessionid': 'SessionID'},
29-
_out_variable_name='OK',
30-
)
31-
def LogoutNotification(ctx, sessionid):
40+
@rpc(LogoutRequest, _returns=LogoutResponse, _body_style='bare')
41+
def LogoutNotification(ctx, req):
3242
# delete user session based on shib session
3343
try:
34-
session_mapping = ShibSession.objects.get(shib=sessionid)
44+
session_mapping = ShibSession.objects.get(shib=req.SessionID)
3545
except:
3646
# Can't delete session
3747
raise Fault(faultcode='Client', faultstring='Invalid session id')
3848
else:
3949
# Deleting session
40-
Session.objects.filter(session_key=session_mapping.session_id).delete()
41-
return True
50+
Session.objects.filter(
51+
session_key=session_mapping.session_id).delete()
52+
return LogoutResponse

shibboleth/urls.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@
1919
url(r'^logoutNotification/', DjangoView.as_view(
2020
services=[LogoutNotificationService],
2121
tns='urn:mace:shibboleth:2.0:sp:notify',
22-
in_protocol=Soap11(), out_protocol=Soap11())),
23-
#FIXME Soap11(validator='lxml') - validation would be nice,
24-
# but needs adjusted model to support logout type attribute
22+
in_protocol=Soap11(validator='lxml'), out_protocol=Soap11())),
2523
]

0 commit comments

Comments
 (0)