Skip to content

Commit

Permalink
Merge pull request #62 from figo-connect/feature-remove-pinning
Browse files Browse the repository at this point in the history
Removed certificate fingerprint check for compatibility with new figo platform
  • Loading branch information
christianhuening authored Apr 16, 2019
2 parents 5137660 + a57cf41 commit 90f11c6
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true
}
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Moritz Pein <[email protected]>
Stefan Löwen <[email protected]>
Stefan Richter <[email protected]>
Stefan Richter <[email protected]>
Yury V. Zaytsev <[email protected]>
achimsen <[email protected]>
berend <[email protected]>
denvercoder9 <[email protected]>
Expand Down
59 changes: 59 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
CHANGES
=======

3.1.0
-----

* removed certificate fingerprint check for compatibility with new figo platform

3.0.4
-----

* version bump to 3.0.4 because of faulty pypi upload

3.0.3
-----

* version bump to 3.0.3
* Remove old fingerprint since the transition is over to silence warnings
* Fix hardcoded fingerprints botched in 3998871

3.0.2
-----

* fix credentials.py

3.0.1
-----

* Added new fingerprint

3.0.0
-----

* fix: task\_start is not called with response.json() anymore
* most of pep8
* clean up of conftest
* added a test for get\_bank
Expand Down Expand Up @@ -72,6 +103,10 @@ CHANGES
1.7.0
-----


v1.6.4
------

* fix import
* fix import
* fix import
Expand Down Expand Up @@ -228,6 +263,10 @@ CHANGES

* bump version to 1.4.1
* added new fingerprint for api.figo.me

v1.4.0
------

* added detailed description to Payment Class
* updated more docstrings
* updated docstrings
Expand All @@ -236,15 +275,35 @@ CHANGES
* changed version
* added add\_user\_and\_login and add\_account\_and\_sync
* added missing api calls, models and test cases

v1.3.2
------

* Adding missing bank\_id to bank
* Remove some typos (non critical) and a debug output
* remove stray space (flake8)

v1.3.1
------

* python 3 compat (and v1.3.1)

v1.3.0
------

* move to new figo.io SDK API level

v1.2.1
------

* increment to v1.2.1
* adding tox.ini to filter out flake8 noise
* flake8 fixes
* adding flake8 to travis CI

v1.2.0
------

* increment version
* adding demo apps
* python 2.6 compat
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ pip install python-figo[webdemo]

# Environment variables

- `FIGO_SSL_FINGERPRINT`
- Override the default fingerprints with a comma seperated list of fingerprints.
- `FIGO_API_ENDPOINT`
- Override the default API endpoint by setting the environment variable.
- `FIGO_CLIENT_ID`, `FIGO_CLIENT_SECRET`
- Override to run tests with a client other than the demo client

4 changes: 0 additions & 4 deletions figo/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
'client_id': 'C-9rtYgOP3mjHhw0qu6Tx9fgk9JfZGmbMqn-rnDZnZwI',
'client_secret': 'Sv9-vNfocFiTe_NoMRkvNLe_jRRFeESHo8A0Uhyp7e28',
'api_endpoint': 'https://api.figo.me',
# string containing comma-separated list of SSL fingerprints
'ssl_fingerprints': 'CD:F3:D3:26:27:89:91:B9:CD:AE:4B:10:6C:96:81:B7:'
'EB:B3:38:10:C4:72:37:6A:4D:9C:84:B7:B3:DC:D6:8D',
}

DEMO_TOKEN = ('ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo'
Expand All @@ -16,5 +13,4 @@
'client_id': os.getenv('FIGO_CLIENT_ID', DEMO_CREDENTIALS['client_id']),
'client_secret': os.getenv('FIGO_CLIENT_SECRET', DEMO_CREDENTIALS['client_secret']),
'api_endpoint': os.getenv('FIGO_API_ENDPOINT', DEMO_CREDENTIALS['api_endpoint']),
'ssl_fingerprints': os.getenv('FIGO_SSL_FINGERPRINT', DEMO_CREDENTIALS['ssl_fingerprints']),
}
31 changes: 6 additions & 25 deletions figo/figo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from datetime import timedelta
from requests.exceptions import SSLError
from requests import Session
from requests_toolbelt.adapters.fingerprint import FingerprintAdapter
from time import sleep

from figo.credentials import CREDENTIALS
Expand Down Expand Up @@ -82,13 +81,11 @@ class FigoObject(object):

def __init__(self,
api_endpoint=CREDENTIALS['api_endpoint'],
fingerprints=CREDENTIALS['ssl_fingerprints'],
language=None):
"""Create a FigoObject instance.
Args:
api_endpoint (str) - base URI of the server to call
fingerprints ([str]) - list of the server's SSL fingerprints
language (str) - language for HTTP request header
"""
self.headers = {
Expand All @@ -98,7 +95,6 @@ def __init__(self,
}
self.language = language
self.api_endpoint = api_endpoint
self.fingerprints = fingerprints.split(',')

def _request_api(self, path, data=None, method="GET"):
"""Helper method for making a REST-compliant API call.
Expand All @@ -117,19 +113,10 @@ def _request_api(self, path, data=None, method="GET"):
session = Session()
session.headers.update(self.headers)

for fingerprint in self.fingerprints:
session.mount(self.api_endpoint, FingerprintAdapter(fingerprint.lower()))
try:
response = session.request(method, complete_path, json=data)
except SSLError:
logging.warn('Fingerprint "%s" was invalid', fingerprint)
else:
break
finally:
session.close()
else:
raise SSLError

try:
response = session.request(method, complete_path, json=data)
finally:
session.close()

if 200 <= response.status_code < 300 or self._has_error(response.json()):
if response.text == '':
Expand Down Expand Up @@ -244,7 +231,6 @@ class FigoConnection(FigoObject):

def __init__(self, client_id, client_secret, redirect_uri,
api_endpoint=CREDENTIALS['api_endpoint'],
fingerprints=CREDENTIALS['ssl_fingerprints'],
language=None):
"""
Create a FigoConnection instance.
Expand All @@ -255,11 +241,9 @@ def __init__(self, client_id, client_secret, redirect_uri,
redirect_uri (str) - the URI the users gets redirected to after the login is finished
or if they press `cancel`
api_endpoint (str) - base URI of the server to call
fingerprints ([str]) - list of the server's SSL fingerprints
language (str) - language for HTTP request header
"""
super(FigoConnection, self).__init__(api_endpoint=api_endpoint, fingerprints=fingerprints,
language=language)
super(FigoConnection, self).__init__(api_endpoint=api_endpoint, language=language)

self.client_id = client_id
self.client_secret = client_secret
Expand Down Expand Up @@ -467,7 +451,6 @@ class FigoSession(FigoObject):
"""
def __init__(self, access_token, sync_poll_retry=20,
api_endpoint=CREDENTIALS['api_endpoint'],
fingerprints=CREDENTIALS['ssl_fingerprints'],
language=None,
):
"""Create a FigoSession instance.
Expand All @@ -476,11 +459,9 @@ def __init__(self, access_token, sync_poll_retry=20,
access_token (str) - the access token to bind this session to a user
sync_poll_retry (int) - maximum number of synchronization poll retries
api_endpoint (str) - base URI of the server to call
fingerprints ([str]) - list of the server's SSL fingerprints
language (str) - language for HTTP request header
"""
super(FigoSession, self).__init__(api_endpoint=api_endpoint, fingerprints=fingerprints,
language=language)
super(FigoSession, self).__init__(api_endpoint=api_endpoint,language=language)

self.access_token = access_token
self.headers.update({'Authorization': "Bearer {0}".format(self.access_token)})
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def figo_connection():
return FigoConnection(CREDENTIALS['client_id'],
CREDENTIALS['client_secret'],
"https://127.0.0.1/",
api_endpoint=CREDENTIALS['api_endpoint'],
fingerprints=CREDENTIALS['ssl_fingerprints'])
api_endpoint=CREDENTIALS['api_endpoint'])


@pytest.fixture(scope='module')
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ commands=py.test {posargs}
passenv =
FIGO_CLIENT_ID
FIGO_CLIENT_SECRET
FIGO_SSL_FINGERPRINT
FIGO_API_ENDPOINT

[testenv:py27]
Expand Down

0 comments on commit 90f11c6

Please sign in to comment.