Skip to content

Commit 457c6f3

Browse files
authored
Merge branch 'development' into SDK-778-Django-Version
2 parents 8e2398c + 7032dcf commit 457c6f3

File tree

11 files changed

+64
-30
lines changed

11 files changed

+64
-30
lines changed

examples/yoti_example_django/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ services:
88
YOTI_CLIENT_SDK_ID: "${YOTI_CLIENT_SDK_ID}"
99
YOTI_KEY_FILE_PATH: "${YOTI_KEY_FILE_PATH}"
1010
ports:
11-
- "5000:5000"
11+
- "5000:5000"

examples/yoti_example_flask/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ services:
88
YOTI_CLIENT_SDK_ID: "${YOTI_CLIENT_SDK_ID}"
99
YOTI_KEY_FILE_PATH: "${YOTI_KEY_FILE_PATH}"
1010
ports:
11-
- "5000:5000"
11+
- "5000:5000"

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
# -*- coding: utf-8 -*-
22
from setuptools import setup, find_packages
33

4-
VERSION = '2.5.0'
4+
from yoti_python_sdk import __version__
5+
56
long_description = 'This package contains the tools you need to quickly ' \
67
'integrate your Python back-end with Yoti, so that your ' \
78
'users can share their identity details with your ' \
89
'application in a secure and trusted way.'
910

1011
setup(
1112
name='yoti',
12-
version=VERSION,
13+
version=__version__,
1314
packages=find_packages(),
1415
license='MIT',
1516
description='The Yoti Python SDK, providing API support for Login, Verify (2FA) and Age Verification.',
1617
long_description=long_description,
1718
url='https://github.com/getyoti/yoti-python-sdk',
1819
author='Yoti',
19-
author_email='tech@yoti.com',
20+
author_email='websdk@yoti.com',
2021
install_requires=['cryptography>=2.2.1', 'protobuf>=3.1.0',
2122
'requests>=2.11.1', 'future>=0.11.0', 'asn1==2.2.0', 'pyopenssl>=18.0.0'],
2223
extras_require={

yoti_python_sdk/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
import os
3+
4+
from distutils.util import convert_path
25
from os import environ
36

47
from yoti_python_sdk.client import Client
@@ -9,11 +12,22 @@
912
'YOTI_API_VERSION': 'v1',
1013
}
1114

15+
main_ns = {}
16+
17+
directory_name = os.path.dirname(__file__)
18+
version_path = os.path.join(directory_name, 'version.py')
19+
20+
ver_path = convert_path(version_path)
21+
with open(ver_path) as ver_file:
22+
exec(ver_file.read(), main_ns)
23+
24+
__version__ = main_ns['__version__']
1225
YOTI_API_URL = environ.get('YOTI_API_URL', DEFAULTS['YOTI_API_URL'])
1326
YOTI_API_PORT = environ.get('YOTI_API_PORT', DEFAULTS['YOTI_API_PORT'])
1427
YOTI_API_VERSION = environ.get('YOTI_API_VERSION', DEFAULTS['YOTI_API_VERSION'])
1528
YOTI_API_ENDPOINT = '{0}:{1}/api/{2}'.format(YOTI_API_URL, YOTI_API_PORT, YOTI_API_VERSION)
1629

1730
__all__ = [
1831
'Client',
32+
__version__
1933
]

yoti_python_sdk/attribute.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33

44
class Attribute:
5-
def __init__(self, name="", value="", anchors={}):
5+
def __init__(self, name="", value="", anchors=None):
6+
if anchors is None:
7+
anchors = {}
68
self.__name = name
79
self.__value = value
810
self.__anchors = anchors

yoti_python_sdk/client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from yoti_python_sdk.crypto import Crypto
1616
from yoti_python_sdk.endpoint import Endpoint
1717
from yoti_python_sdk.protobuf.v1 import protobuf
18-
from .config import SDK_IDENTIFIER
18+
from .config import *
1919

2020
NO_KEY_FILE_SPECIFIED_ERROR = 'Please specify the correct private key file ' \
2121
'in Client(pem_file_path=...)\nor by setting ' \
@@ -112,13 +112,15 @@ def __make_aml_check_request(self, http_method, aml_profile):
112112

113113
def __get_request_headers(self, path, http_method, content):
114114
request = self.__create_request(http_method, path, content)
115+
sdk_version = yoti_python_sdk.__version__
115116

116117
return {
117-
'X-Yoti-Auth-Key': self.__crypto.get_public_key(),
118-
'X-Yoti-Auth-Digest': self.__crypto.sign(request),
119-
'X-Yoti-SDK': SDK_IDENTIFIER,
120-
'Content-Type': 'application/json',
121-
'Accept': 'application/json'
118+
X_YOTI_AUTH_KEY: self.__crypto.get_public_key(),
119+
X_YOTI_AUTH_DIGEST: self.__crypto.sign(request),
120+
X_YOTI_SDK: SDK_IDENTIFIER,
121+
X_YOTI_SDK_VERSION: sdk_version,
122+
'Content-Type': JSON_CONTENT_TYPE,
123+
'Accept': JSON_CONTENT_TYPE
122124
}
123125

124126
@staticmethod

yoti_python_sdk/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@
1818
KEY_AGE_VERIFIED = "is_age_verified"
1919
KEY_BASE64_SELFIE = "base64_selfie_uri"
2020
KEY_FORMATTED_ADDRESS = "formatted_address"
21+
X_YOTI_AUTH_KEY = "X-Yoti-Auth-Key"
22+
X_YOTI_AUTH_DIGEST = "X-Yoti-Auth-Digest"
23+
X_YOTI_SDK = "X-Yoti-SDK"
24+
X_YOTI_SDK_VERSION = X_YOTI_SDK + "-Version"
25+
JSON_CONTENT_TYPE = 'application/json'

yoti_python_sdk/profile.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, profile_attributes):
2626
if field.name == config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS:
2727
self.try_convert_structured_postal_address_to_dict(field, anchors)
2828

29-
self.ensure_postal_address(anchors)
29+
self.ensure_postal_address()
3030

3131
@property
3232
def date_of_birth(self):
@@ -78,7 +78,6 @@ def get_attribute(self, attribute_name):
7878
else:
7979
return None
8080

81-
8281
def try_convert_structured_postal_address_to_dict(self, field, anchors):
8382
decoder = json.JSONDecoder(object_pairs_hook=collections.OrderedDict, strict=False)
8483
value_to_decode = field.value.decode()
@@ -88,12 +87,14 @@ def try_convert_structured_postal_address_to_dict(self, field, anchors):
8887
decoder.decode(value_to_decode),
8988
anchors)
9089

91-
def ensure_postal_address(self, anchors):
90+
def ensure_postal_address(self):
9291
if config.ATTRIBUTE_POSTAL_ADDRESS not in self.attributes and config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS in self.attributes:
93-
if config.KEY_FORMATTED_ADDRESS in self.attributes[config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS].value:
94-
formatted_address = self.attributes[config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS].value[
92+
structured_postal_address = self.attributes[config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS]
93+
94+
if config.KEY_FORMATTED_ADDRESS in structured_postal_address.value:
95+
formatted_address = structured_postal_address.value[
9596
config.KEY_FORMATTED_ADDRESS]
9697
self.attributes[config.ATTRIBUTE_POSTAL_ADDRESS] = Attribute(
9798
config.ATTRIBUTE_POSTAL_ADDRESS,
9899
formatted_address,
99-
anchors)
100+
structured_postal_address.anchors)

yoti_python_sdk/protobuf/v1/protobuf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from __future__ import unicode_literals
33

44
from cryptography.fernet import base64
5-
from yoti_python_sdk.protobuf.v1.attribute_public_api import attribute_pb2, list_pb2
65

76
import yoti_python_sdk.protobuf.v1.common_public_api.encrypted_data_pb2 as compubapi
7+
from yoti_python_sdk.protobuf.v1.attribute_public_api import attribute_pb2, list_pb2
88

99

1010
class Protobuf(object):

yoti_python_sdk/tests/test_client.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
except ImportError:
1717
import mock
1818

19+
import yoti_python_sdk
1920
from yoti_python_sdk import YOTI_API_ENDPOINT
2021
from yoti_python_sdk import Client
2122
from yoti_python_sdk import aml
22-
from yoti_python_sdk.config import SDK_IDENTIFIER
23+
from yoti_python_sdk.config import *
2324
from yoti_python_sdk.client import NO_KEY_FILE_SPECIFIED_ERROR
2425
from yoti_python_sdk.activity_details import ActivityDetails
2526
from yoti_python_sdk.tests.conftest import YOTI_CLIENT_SDK_ID, PEM_FILE_PATH
@@ -41,23 +42,29 @@
4142

4243
@pytest.fixture(scope='module')
4344
def expected_get_headers(x_yoti_auth_key, x_yoti_auth_digest_get):
45+
sdk_version = yoti_python_sdk.__version__
46+
4447
return {
45-
'Content-Type': 'application/json',
46-
'Accept': 'application/json',
47-
'X-Yoti-Auth-Key': x_yoti_auth_key,
48-
'X-Yoti-Auth-Digest': x_yoti_auth_digest_get,
49-
'X-Yoti-SDK': SDK_IDENTIFIER
48+
'Content-Type': JSON_CONTENT_TYPE,
49+
'Accept': JSON_CONTENT_TYPE,
50+
X_YOTI_AUTH_KEY: x_yoti_auth_key,
51+
X_YOTI_AUTH_DIGEST: x_yoti_auth_digest_get,
52+
X_YOTI_SDK: SDK_IDENTIFIER,
53+
X_YOTI_SDK_VERSION: sdk_version
5054
}
5155

5256

5357
@pytest.fixture(scope='module')
5458
def expected_post_headers(x_yoti_auth_key, x_yoti_auth_digest_post):
59+
sdk_version = yoti_python_sdk.__version__
60+
5561
return {
56-
'X-Yoti-Auth-Key': x_yoti_auth_key,
57-
'X-Yoti-Auth-Digest': x_yoti_auth_digest_post,
58-
'X-Yoti-SDK': SDK_IDENTIFIER,
59-
'Content-Type': 'application/json',
60-
'Accept': 'application/json'
62+
X_YOTI_AUTH_KEY: x_yoti_auth_key,
63+
X_YOTI_AUTH_DIGEST: x_yoti_auth_digest_post,
64+
X_YOTI_SDK: SDK_IDENTIFIER,
65+
X_YOTI_SDK_VERSION: sdk_version,
66+
'Content-Type': JSON_CONTENT_TYPE,
67+
'Accept': JSON_CONTENT_TYPE
6168
}
6269

6370

0 commit comments

Comments
 (0)