allow selecting password or strong authentication

This commit is contained in:
Kevin P 2012-11-20 18:43:18 +01:00 committed by Romain Bignon
commit 9d3cc588f2
3 changed files with 23 additions and 13 deletions

View file

@ -36,14 +36,21 @@ class CreditCooperatifBackend(BaseBackend, ICapBank):
VERSION = '0.d'
DESCRIPTION = u'Credit Cooperatif French bank website'
LICENSE = 'AGPLv3+'
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False),
auth_type = {"weak" : "Code confidentiel",
"strong": "Sesame"}
CONFIG = BackendConfig(Value('auth_type', label='Authentication type', choices=auth_type, default="strong"),
ValueBackendPassword('login', label='Account ID', masked=False),
ValueBackendPassword('pin', label='One time pin'))
BROWSER = CreditCooperatif
def create_default_browser(self):
print self.config['login'].get()
print self.config['auth_type'].get()
return self.create_browser(self.config['login'].get(),
self.config['pin'].get())
self.config['pin'].get(),
self.config['auth_type'].get() == "strong")
def iter_accounts(self):
with self.browser:

View file

@ -38,10 +38,11 @@ class CreditCooperatif(BaseBrowser):
'https://www.coopanet.com/banque/cpt/cpt/relevecompte.do\?tri_page=.*': TransactionsPage,
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkOpCB=X&numeroExterne=.*': ComingTransactionsPage
}
def __init__(self, *args, **kwargs):
BaseBrowser.__init__(self, *args, **kwargs)
self.token = None
#catch and remove the third/last arg
self.strong_auth = args[-1]
BaseBrowser.__init__(self, *args[:-1], **kwargs)
def home(self):
self.location("/banque/sso/")
@ -59,6 +60,7 @@ class CreditCooperatif(BaseBrowser):
assert isinstance(self.username, basestring)
assert isinstance(self.password, basestring)
assert isinstance(self.strong_auth, bool)
if self.is_logged():
return
@ -66,23 +68,20 @@ class CreditCooperatif(BaseBrowser):
if not self.is_on_page(LoginPage):
self.home()
self.page.login(self.username, self.password)
self.page.login(self.username, self.password, self.strong_auth)
if not self.is_logged():
raise BrowserIncorrectPassword()
def get_accounts_list(self):
self.location(self.buildurl('/banque/cpt/incoopanetj2ee.do?ssomode=ok'))
if self.page.is_error():
self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID='maSyntheseGratuite', token=self.token))
return self.page.get_list()
def get_account(self, id):
assert isinstance(id, basestring)
l = self.get_accounts_list()
for a in l:
for a in self.get_accounts_list():
if a.id == id:
return a
@ -90,6 +89,7 @@ class CreditCooperatif(BaseBrowser):
def get_history(self, account):
self.location('/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne='+ account.id)
while 1:
assert self.is_on_page(TransactionsPage)

View file

@ -30,12 +30,15 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
__all__ = ['LoginPage', 'AccountsPage', 'TransactionsPage', 'ComingTransactionsPage']
class LoginPage(BasePage):
def login(self, login, pin):
self.browser.select_form(name='loginCoForm', nr=1)
def login(self, login, pin, strong_auth):
form_nb = 1 if strong_auth else 0
indentType = "RENFORCE" if strong_auth else "MDP"
self.browser.select_form(name='loginCoForm', nr=form_nb)
self.browser['codeUtil'] = login
self.browser['motPasse'] = pin
assert self.browser['identType'] == "RENFORCE"
assert self.browser['identType'] == indentType
self.browser.submit(nologin=True)
class AccountsPage(BasePage):