File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 4
4
from django .core .exceptions import ImproperlyConfigured
5
5
6
6
from shibboleth .app_settings import SHIB_ATTRIBUTE_MAP , GROUP_ATTRIBUTES
7
+ from shibboleth .models import ShibSession
7
8
8
9
9
10
class ShibbolethRemoteUserMiddleware (RemoteUserMiddleware ):
@@ -56,7 +57,10 @@ def process_request(self, request):
56
57
# by logging the user in.
57
58
request .user = user
58
59
auth .login (request , user )
59
-
60
+
61
+ # store session mapping
62
+ ShibSession .objects .get_or_create (shib = request .META ['Shib_Session_ID' ], session_id = request .session .session_key )
63
+
60
64
# Upgrade user groups if configured in the settings.py
61
65
# If activated, the user will be associated with those groups.
62
66
if GROUP_ATTRIBUTES :
Original file line number Diff line number Diff line change 1
- #intentionally left blank
1
+ from django .db import models
2
+ from django .contrib .sessions .models import Session
3
+
4
+
5
+ class ShibSession (models .Model ):
6
+ shib = models .CharField (max_length = 100 , primary_key = True )
7
+ session = models .ForeignKey (Session , on_delete = models .CASCADE )
Original file line number Diff line number Diff line change 6
6
from django .shortcuts import redirect
7
7
from django .utils .decorators import method_decorator
8
8
from django .views .generic import TemplateView
9
+ from django .contrib .sessions .models import Session
9
10
10
11
try :
11
12
from django .utils .six .moves .urllib .parse import quote
14
15
15
16
#Logout settings.
16
17
from shibboleth .app_settings import LOGOUT_URL , LOGOUT_REDIRECT_URL
18
+ from shibboleth .models import ShibSession
17
19
18
20
#SLO (back-channel) / spyne stuff
19
21
from spyne .model .primitive import Unicode
@@ -101,6 +103,13 @@ class LogoutNotificationService(Service):
101
103
_out_variable_name = 'OK' ,
102
104
)
103
105
def LogoutNotification (ctx , sessionid ):
104
- #return 'Session: %s' % sessionid
105
- #TODO Do logout stuff here - delete user session based on shib session
106
- return True
106
+ # delete user session based on shib session
107
+ try :
108
+ session_mapping = ShibSession .objects .get (shib = sessionid )
109
+ except :
110
+ # Can't delete session
111
+ raise
112
+ else :
113
+ # Deleting session
114
+ Session .objects .filter (session_key = session_mapping .session_id ).delete ()
115
+ return True
You can’t perform that action at this time.
0 commit comments