changeset 5117:2f7bab994988

cas auth: simplify PyCAS, fix logout path
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 01 Sep 2009 12:11:19 +0200
parents 2008204d7c1a
children 845ff5cd3890
files MoinMoin/auth/cas.py
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/cas.py	Tue Sep 01 12:03:56 2009 +0200
+++ b/MoinMoin/auth/cas.py	Tue Sep 01 12:11:19 2009 +0200
@@ -22,33 +22,31 @@
 class PyCAS(object):
     """A class for working with a CAS server."""
 
-    def __init__(self, url, renew=False, **kwords):
+    def __init__(self, url, renew=False, login_path='/login', logout_path='/logout',
+                 validate_path='/validate'):
         self.url = url
         self.renew = renew
-        self.paths = {
-            'login_path': '/login',
-            'logout_path': '/login',
-            'validate_path': '/validate',
-        }
-        self.paths.update(kwords)
+        self.login_path = login_path
+        self.logout_path = logout_path
+        self.validate_path = validate_path
 
     def login_url(self, service):
         """Return the login URL for the given service."""
-        base = self.url + self.paths['login_path'] + '?service=' + urllib.quote_plus(service)
+        base = self.url + self.login_path + '?service=' + urllib.quote_plus(service)
         if self.renew:
             base += "&renew=true"
         return base
 
     def logout_url(self, url=None):
         """Return the logout URL."""
-        base = self.url + self.paths['logout_path']
+        base = self.url + self.logout_path
         if url:
             base += '?url=' + urllib.quote_plus(url)
         return base
 
     def validate_url(self, service, ticket):
         """Return the validation URL for the given service. (For CAS 1.0)"""
-        base = self.url + self.paths['validate_path'] + '?service=' + urllib.quote_plus(service) + '&ticket=' + urllib.quote_plus(ticket)
+        base = self.url + self.validate_path + '?service=' + urllib.quote_plus(service) + '&ticket=' + urllib.quote_plus(ticket)
         if self.renew:
             base += "&renew=true"
         return base