diff --git a/azure/azure-pr-teardown-pipeline.yml b/azure/azure-pr-teardown-pipeline.yml index 88d989631..0051c39c0 100644 --- a/azure/azure-pr-teardown-pipeline.yml +++ b/azure/azure-pr-teardown-pipeline.yml @@ -57,7 +57,7 @@ jobs: - bash: | export AWS_PROFILE=apim-dev - cd mns_subscription + cd lambdas/mns_subscription echo "unsubscribing SQS Queue from MNS notifications." pyenv install -s 3.11.11 diff --git a/lambdas/shared/src/common/authentication.py b/lambdas/shared/src/common/authentication.py index 63e78d745..899bf2152 100644 --- a/lambdas/shared/src/common/authentication.py +++ b/lambdas/shared/src/common/authentication.py @@ -48,26 +48,13 @@ def create_jwt(self, now: int): "exp": now + self.expiry, "jti": str(uuid.uuid4()) } - logger.info(f"JWT claims: {claims}") - # ✅ Version-compatible JWT encoding - try: - # PyJWT 2.x - return jwt.encode( - claims, - secret_object['private_key'], - algorithm='RS512', - headers={"kid": secret_object['kid']} - ) - except TypeError: - # PyJWT 1.x (older versions return bytes) - token = jwt.encode( - claims, - secret_object['private_key'], - algorithm='RS512', - headers={"kid": secret_object['kid']} - ) - # Convert bytes to string if needed - return token.decode('utf-8') if isinstance(token, bytes) else token + + return jwt.encode( + claims, + secret_object['private_key'], + algorithm='RS512', + headers={"kid": secret_object['kid']} + ) def get_access_token(self): logger.info("get_access_token") @@ -77,7 +64,7 @@ def get_access_token(self): logger.info(f"Cache key: {self.cache_key}") logger.info("Checking cache for access token") cached = self.cache.get(self.cache_key) - logger.info(f"Cached token: {cached}") + if cached and cached["expires_at"] > now: logger.info("Returning cached access token") return cached["token"] @@ -85,8 +72,6 @@ def get_access_token(self): logger.info("No valid cached token found, creating new token") _jwt = self.create_jwt(now) - logger.info(f"JWT created: {_jwt}") - headers = { 'Content-Type': 'application/x-www-form-urlencoded' }