Skip to content

Commit 174e233

Browse files
committed
Sem-Ver: feature Cache Backend verifiers.
Signed-off-by: David Black <[email protected]>
1 parent 3c7ad29 commit 174e233

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

atlassian_jwt_auth/frameworks/common/backend.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from abc import ABCMeta, abstractmethod, abstractproperty
2+
try:
3+
from functools import lru_cache
4+
except ImportError:
5+
from backports.functools_lru_cache import lru_cache
26

37
from atlassian_jwt_auth import HTTPSPublicKeyRetriever, JWTAuthVerifier
48

@@ -85,7 +89,10 @@ def get_verifier(self, settings=None):
8589
"""Returns a verifier for ASAP JWT tokens"""
8690
if settings is None:
8791
settings = self.settings
92+
return self._get_verifier(settings)
8893

94+
@lru_cache(maxsize=130)
95+
def _get_verifier(self, settings):
8996
retriever = settings.ASAP_KEY_RETRIEVER_CLASS(
9097
base_url=settings.ASAP_PUBLICKEY_REPOSITORY
9198
)

atlassian_jwt_auth/frameworks/flask/tests/test_flask.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def test_request_with_valid_token_is_allowed(self):
6464
)
6565
self.assertEqual(self.send_request(token).status_code, 200)
6666

67-
@unittest.expectedFailure
6867
def test_request_with_duplicate_jti_is_rejected(self):
6968
token = create_token(
7069
'client-app', 'server-app',

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ cryptography>=2.8.0,<2.9.0
22
PyJWT>=1.5.2,<2.0.0
33
requests>=2.8.1,<3.0.0
44
CacheControl==0.12.6
5+
backports.functools-lru-cache==1.6.1

0 commit comments

Comments
 (0)