From 3e441237d4e96244ea3d9ed0546c4781a405324e Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 19 Dec 2023 14:40:16 -0700 Subject: [PATCH] use str where we should --- giftless/auth/jwt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/giftless/auth/jwt.py b/giftless/auth/jwt.py index e1ff8ab..60ee564 100644 --- a/giftless/auth/jwt.py +++ b/giftless/auth/jwt.py @@ -151,7 +151,7 @@ def _generate_token_for_action(self, identity: Identity, org: str, repo: str, ac if lifetime: token_payload['exp'] = datetime.now(tz=UTC) + timedelta(seconds=lifetime) - return self._generate_token(**token_payload).decode('ascii') + return self._generate_token(**token_payload) @staticmethod def _generate_action_scopes(org: str, repo: str, actions: Optional[Set[str]] = None, oid: Optional[str] = None) \ @@ -163,7 +163,7 @@ def _generate_action_scopes(org: str, repo: str, actions: Optional[Set[str]] = N obj_id = f'{org}/{repo}/{oid}' return str(Scope('obj', obj_id, actions)) - def _generate_token(self, **kwargs) -> bytes: + def _generate_token(self, **kwargs) -> str: """Generate a JWT token that can be used later to authenticate a request """ if not self.private_key: @@ -187,9 +187,9 @@ def _generate_token(self, **kwargs) -> bytes: if self.key_id: headers['kid'] = self.key_id - return jwt.encode(payload, self.private_key, algorithm=self.algorithm, headers=headers) # type: ignore + return jwt.encode(payload, self.private_key, algorithm=self.algorithm, headers=headers) - def _authenticate(self, request: Request): + def _authenticate(self, request: Request) -> Any: """Authenticate a request """ token = self._get_token_from_headers(request)