Changeset 10398 for main/waeup.cas/trunk/waeup/cas/server.py
- Timestamp:
- 4 Jul 2013, 22:08:53 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/server.py
r10397 r10398 100 100 101 101 102 def check_session_cookie(db, cookie_value): 103 """Check whether `cookie_value` represents a valid ticket granting 104 ticket in `db`. 105 """ 106 if cookie_value is None: 107 return False 108 print("VAL1: ", cookie_value) 109 try: 110 # turn value into unicode (py2.x) / str (py3.x) 111 cookie_value = cookie_value.decode('utf-8') 112 except AttributeError: # pragma: no cover 113 pass 114 print("VAL2: ", cookie_value) 115 q = db.query(TicketGrantingCookie).filter( 116 TicketGrantingCookie.value == cookie_value) 117 result = [x for x in q] 118 if len(result): 119 return result[0] 120 return None 121 122 102 123 class CASServer(object): 103 124 """A WSGI CAS server. … … 142 163 password = req.POST.get('password', None) 143 164 valid_lt = check_login_ticket(self.db, req.POST.get('lt')) 144 if username and password and valid_lt: 165 tgc = req.cookies.get('cas-tgc', None) 166 print('TGC: ', tgc) 167 tgc = check_session_cookie(self.db, tgc) 168 print("TGC2: ", tgc) 169 print([(x, y) for x, y, in req.headers.items()]) 170 if username and password and valid_lt or tgc: 145 171 # act as credentials acceptor 146 cred_ok, reason = self.auth.check_credentials(username, password) 172 if tgc: 173 cred_ok, reason = True, '' 174 if not service: 175 msg = 'You logged in already.' 176 else: 177 cred_ok, reason = self.auth.check_credentials( 178 username, password) 147 179 if cred_ok: 148 180 if service is None: 149 181 # show logged-in screen 150 182 html = self._get_template('login_successful.html') 183 html = html.replace('MSG_TEXT', msg) 151 184 resp = Response(html) 152 resp = set_session_cookie(resp, self.db) 185 if not tgc: 186 resp = set_session_cookie(resp, self.db) 153 187 return resp 154 188 else:
Note: See TracChangeset for help on using the changeset viewer.