Changeset 10413
- Timestamp:
- 7 Jul 2013, 08:02:18 (11 years ago)
- Location:
- main/waeup.cas/trunk/waeup/cas
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/server.py
r10412 r10413 133 133 134 134 135 def login_redirect_service(db, service, sso=True, create_ticket=True): 135 def login_redirect_service(db, service, sso=True, create_ticket=True, 136 warn=False): 136 137 """Return a response redirecting to a service via HTTP 303 See Other. 137 138 """ 138 # safely redirect to service given139 139 if create_ticket: 140 140 st = create_service_ticket(service, sso) … … 142 142 service = '%s?ticket=%s' % (service, st.ticket) 143 143 html = get_template('login_service_redirect.html') 144 if warn: 145 html = get_template('login_service_confirm.html') 144 146 html = html.replace('SERVICE_URL', service) 145 147 resp = exc.HTTPSeeOther(location=service) 148 if warn: 149 resp = Response() 146 150 # try to forbid caching of any type 147 151 resp.cache_control = 'no-store' … … 210 214 service = req.POST.get('service', req.GET.get('service', None)) 211 215 renew = req.POST.get('renew', req.GET.get('renew', None)) 216 warn = req.POST.get('warn', req.GET.get('warn', False)) 212 217 gateway = req.POST.get('gateway', req.GET.get('gateway', None)) 213 218 if renew is not None and gateway is not None: … … 224 229 if tgc and (renew is None): 225 230 if service: 226 return login_redirect_service(self.db, service, sso=True) 231 return login_redirect_service( 232 self.db, service, sso=True, warn=warn) 227 233 else: 228 234 return login_success_no_service( … … 238 244 else: 239 245 # safely redirect to service given 240 return login_redirect_service(self.db, service, sso=False) 246 return login_redirect_service( 247 self.db, service, sso=False, warn=warn) 241 248 else: 242 249 # login failed -
main/waeup.cas/trunk/waeup/cas/tests/test_server.py
r10412 r10413 200 200 assert b'username' in resp.body 201 201 assert 'Set-Cookie' not in resp.headers 202 203 def test_login_warn(self): 204 # 2.2.1 as a credential acceptor, with `warn` set we require confirm 205 app = CASServer() 206 tgc = create_tgc_value() 207 app.db.add(tgc) 208 value = str(tgc.value) 209 params = 'warn=true&service=http%3A%2F%2Fwww.service.com' 210 req = Request.blank('https://localhost/login?%s' % params) 211 req.headers['Cookie'] = 'cas-tgc=%s' % value 212 resp = app(req) 213 # without warn, we would get a redirect 214 assert resp.status == '200 OK' 215 assert b'CAS login successful' in resp.body 202 216 203 217
Note: See TracChangeset for help on using the changeset viewer.