Skip to content

Commit a1dba2d

Browse files
committed
Merge pull request #137 from box/jwt_fixes
Fixes to JWTAuth
2 parents 481a862 + 1d1559a commit a1dba2d

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

HISTORY.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ Release History
66
Upcoming
77
++++++++
88

9-
1.5.2
9+
1.5.3
10+
++++++++++++++++++
11+
12+
- Bugfix so that ``JWTAuth`` opens the PEM private key file in ``'rb'`` mode.
13+
14+
1.5.2 (2016-05-19)
1015
++++++++++++++++++
1116

1217
- Bugfix so that ``OAuth2`` always has the correct tokens after a call to ``refresh()``.

boxsdk/auth/jwt_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
from __future__ import unicode_literals
3+
from __future__ import absolute_import, unicode_literals
44

55
from datetime import datetime, timedelta
66
import random
@@ -95,7 +95,7 @@ def __init__(
9595
refresh_token=None,
9696
network_layer=network_layer,
9797
)
98-
with open(rsa_private_key_file_sys_path) as key_file:
98+
with open(rsa_private_key_file_sys_path, 'rb') as key_file:
9999
self._rsa_private_key = serialization.load_pem_private_key(
100100
key_file.read(),
101101
password=rsa_private_key_passphrase,
@@ -182,6 +182,7 @@ def authenticate_instance(self):
182182
:rtype:
183183
`unicode`
184184
"""
185+
self._user_id = None
185186
return self._auth_with_jwt(self._enterprise_id, 'enterprise')
186187

187188
def _refresh(self, access_token):

boxsdk/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from __future__ import unicode_literals, absolute_import
44

55

6-
__version__ = '1.5.2'
6+
__version__ = '1.5.3'

test/unit/auth/test_jwt_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def jwt_auth_init_mocks(
7373
}
7474

7575
mock_network_layer.request.return_value = successful_token_response
76-
key_file_read_data = 'key_file_read_data'
76+
key_file_read_data = b'key_file_read_data'
7777
with patch('boxsdk.auth.jwt_auth.open', mock_open(read_data=key_file_read_data), create=True) as jwt_auth_open:
7878
with patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') as load_pem_private_key:
7979
oauth = JWTAuth(
@@ -88,7 +88,7 @@ def jwt_auth_init_mocks(
8888
jwt_key_id=jwt_key_id,
8989
)
9090

91-
jwt_auth_open.assert_called_once_with(sentinel.rsa_path)
91+
jwt_auth_open.assert_called_once_with(sentinel.rsa_path, 'rb')
9292
jwt_auth_open.return_value.read.assert_called_once_with() # pylint:disable=no-member
9393
load_pem_private_key.assert_called_once_with(
9494
key_file_read_data,

0 commit comments

Comments
 (0)