[wiki/auth/cas] redirection vers le wiki au logout, paramètres pour l'url de fallback,

possibiliter de forcer une réauthentification sur le CAS.
This commit is contained in:
Valentin Samir 2013-05-21 18:27:31 +02:00
parent 19eb6c8e7b
commit 8912112191

View file

@ -43,6 +43,7 @@ class PyCAS(object):
url = self.server_url + self.logout_path url = self.server_url + self.logout_path
if redirect_url: if redirect_url:
url += '?url=' + urllib.quote_plus(redirect_url) url += '?url=' + urllib.quote_plus(redirect_url)
url += '&service=' + urllib.quote_plus(redirect_url)
return url return url
def validate_url(self, service, ticket): def validate_url(self, service, ticket):
@ -78,12 +79,13 @@ class CASAuth(BaseAuth):
def request(self, request, user_obj, **kw): def request(self, request, user_obj, **kw):
ticket = request.args.get("ticket", "") ticket = request.args.get("ticket", "")
action = request.args.get("action", "") action = request.args.get("action", "")
force = request.args.get("force", None) is not None
logoutRequest = request.args.get("logoutRequest", []) logoutRequest = request.args.get("logoutRequest", [])
p = urlparse.urlparse(request.url) p = urlparse.urlparse(request.url)
url = urlparse.urlunparse(('https', p.netloc, p.path, "", "", "")) url = urlparse.urlunparse(('https', p.netloc, p.path, "", "", ""))
# authenticated user # authenticated user
if user_obj and user_obj.valid: if not force and user_obj and user_obj.valid:
return user_obj, True return user_obj, True
# anonymous # anonymous
@ -102,7 +104,7 @@ class CASAuth(BaseAuth):
else: else:
u.valid = u.exists() u.valid = u.exists()
if self.fallback_url and not u.valid: if self.fallback_url and not u.valid:
request.http_redirect(self.fallback_url) request.http_redirect("%s?action=%s&wiki_url=%s" % (self.fallback_url, self.action, url))
return u, True return u, True
# login # login