Skip to content

Commit 5a21ca7

Browse files
Make linters happy
1 parent add7bf0 commit 5a21ca7

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

guardpost/jwts/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Dict, Optional, Sequence, List, Union, Protocol
1+
from abc import ABC, abstractmethod
2+
from typing import Any, Dict, List, Optional, Protocol, Sequence, Union
23

34
import jwt
45
from jwt.exceptions import InvalidIssuerError, InvalidTokenError
@@ -36,10 +37,14 @@ def get_kid(token: str) -> Optional[str]:
3637
class JWTValidatorProtocol(Protocol):
3738
"""Protocol defining the interface for JWT validators"""
3839

39-
async def validate_jwt(self, access_token: str) -> Dict[str, Any]: ...
40+
async def validate_jwt(self, access_token: str) -> Dict[str, Any]:
41+
"""
42+
Validates an access token and returns its claims.
43+
"""
44+
...
4045

4146

42-
class BaseJWTValidator:
47+
class BaseJWTValidator(ABC):
4348
"""Base class for JWT validators with common functionality."""
4449

4550
def __init__(
@@ -54,6 +59,12 @@ def __init__(
5459
self._algorithms = list(algorithms)
5560
self.logger = get_logger()
5661

62+
@abstractmethod
63+
async def validate_jwt(self, access_token: str) -> Dict[str, Any]:
64+
"""
65+
Validates an access token and returns its claims.
66+
"""
67+
5768

5869
class AsymmetricJWTValidator(BaseJWTValidator):
5970
"""
@@ -235,8 +246,8 @@ def __init__(
235246
for algorithm in algorithms:
236247
if algorithm not in supported_algorithms:
237248
raise ValueError(
238-
f"Algorithm '{algorithm}' is not supported for symmetric validation. "
239-
f"Use one of: {', '.join(supported_algorithms)}"
249+
f"Algorithm '{algorithm}' is not supported for symmetric "
250+
f"validation. Use one of: {', '.join(supported_algorithms)}."
240251
)
241252

242253
self._secret_key = secret_key

tests/res/genjwks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Functions to generate RSA keys and JWKS.
33
"""
4+
45
import base64
56
import json
67

tests/serverfixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import json
22
import os
3+
from importlib.resources import files
34
from multiprocessing import Process
45
from time import sleep
56

6-
from importlib.resources import files
77
import pytest
88
from flask import Flask
99

0 commit comments

Comments
 (0)