Skip to content

Commit

Permalink
use str where we should
Browse files Browse the repository at this point in the history
  • Loading branch information
athornton committed Dec 19, 2023
1 parent 508c014 commit 3e44123
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions giftless/auth/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand All @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 3e44123

Please sign in to comment.