lcl: support new auth system

This commit is contained in:
Romain Bignon 2013-07-21 19:10:16 +02:00
commit bb430b3078
3 changed files with 17 additions and 8 deletions

View file

@ -39,7 +39,7 @@ class LCLBackend(BaseBackend, ICapBank):
LICENSE = 'AGPLv3+'
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', regexp='^\d+\w$', masked=False),
ValueBackendPassword('password', label='Password of account', regexp='^\d{6}$'),
Value('agency', label='Agency code', regexp='^\d{3,4}$'))
Value('agency', label='Agency code (deprecated)', regexp='^(\d{3,4}|)$', default=''))
BROWSER = LCLBrowser
def create_default_browser(self):

View file

@ -40,6 +40,7 @@ class LCLBrowser(BaseBrowser):
'https://particuliers.secure.lcl.fr/outil/UAUT/Authentication/authenticate': LoginPage,
'https://particuliers.secure.lcl.fr/outil/UAUT\?from=.*': LoginPage,
'https://particuliers.secure.lcl.fr/outil/UAUT/Accueil/preRoutageLogin': LoginPage,
'https://particuliers.secure.lcl.fr//outil/UAUT/Contract/routing': LoginPage,
'https://particuliers.secure.lcl.fr/outil/UAUT/Contrat/choixContrat.*': ContractsPage,
'https://particuliers.secure.lcl.fr/outil/UWSP/Synthese': AccountsPage,
'https://particuliers.secure.lcl.fr/outil/UWLM/ListeMouvements.*/accesListeMouvements.*': AccountHistoryPage,
@ -60,16 +61,13 @@ class LCLBrowser(BaseBrowser):
assert isinstance(self.username, basestring)
assert isinstance(self.password, basestring)
assert self.password.isdigit()
assert isinstance(self.agency, basestring)
assert self.agency.isdigit()
if not self.is_on_page(LoginPage):
self.location('%s://%s/outil/UAUT/Authentication/authenticate'
% (self.PROTOCOL, self.DOMAIN),
no_login=True)
if not self.page.login(self.agency, self.username, self.password) or \
not self.is_logged() or \
if not self.page.login(self.username, self.password, self.agency) or \
(self.is_on_page(LoginPage) and self.page.is_error()) :
raise BrowserIncorrectPassword("invalid login/password.\nIf you did not change anything, be sure to check for password renewal request\non the original web site.\nAutomatic renewal will be implemented later.")
self.location('%s://%s/outil/UWSP/Synthese'

View file

@ -75,13 +75,21 @@ class SkipPage(BasePage):
class LoginPage(BasePage):
def on_loaded(self):
try:
self.browser.select_form(name='form')
except:
pass
else:
self.browser.submit(nologin=True)
def myXOR(self,value,seed):
s=''
for i in xrange(len(value)):
s+=chr(seed^ord(value[i]))
return s
def login(self, agency, login, passwd):
def login(self, login, passwd, agency):
try:
vk=LCLVirtKeyboard(self)
except VirtKeyboardError,err:
@ -106,8 +114,11 @@ class LoginPage(BasePage):
self.browser.select_form(
predicate=lambda x: x.attrs.get('id','')=='formAuthenticate')
self.browser.form.set_all_readonly(False)
self.browser['agenceId'] = agency
self.browser['compteId'] = login
if len(agency) > 0:
self.browser['agenceId'] = agency.encode('utf-8')
self.browser['compteId'] = login.encode('utf-8')
else:
self.browser['identifiant'] = login.encode('utf-8')
self.browser['postClavierXor'] = base64.b64encode(self.myXOR(password,seed))
try:
self.browser.submit(nologin=True)