Changeset 10478 for main/waeup.cas/trunk/waeup/cas/authenticators.py
- Timestamp:
- 12 Aug 2013, 08:52:26 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/authenticators.py
r10475 r10478 3 3 import re 4 4 from pkg_resources import iter_entry_points 5 try: 6 import xmlrpclib # Python 2.x 7 except ImportError: # pragma: no cover 8 import xmlrpc.client as xmlrpclib # Python 3.x 5 9 6 10 … … 112 116 113 117 118 #: Regular expression matching a starting university marker like 119 #: the string 'MA-' in 'MA-M121212' or 'MA-' in 'MA-APP-13123' 120 RE_SCHOOL_MARKER = re.compile('^[^\-]+-') 121 122 114 123 class KofaAuthenticator(Authenticator): 115 124 """Authenticate against a running Kofa instance. … … 148 157 """Do the real check. 149 158 """ 150 return False, 'Not implemented.' 159 for backend_name, backend in self.backends.items(): 160 if not re.match(backend['marker'], username): 161 continue 162 # remove school marker 163 username = RE_SCHOOL_MARKER.sub('', username) 164 proxy = xmlrpclib.ServerProxy( 165 backend['url'], allow_none=True) 166 valid = proxy.check_credentials(username, password) 167 if valid is not None: 168 return (True, '') 169 return (False, 'Invalid username or password.')
Note: See TracChangeset for help on using the changeset viewer.