Skip to content

Commit

Permalink
Add return code for TokenExpired
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitlock committed Jan 18, 2025
1 parent cbef10f commit e17060f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 3 additions & 2 deletions api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import shlex
from datetime import UTC, datetime
from hashlib import sha256
from typing import Any, Literal, NoReturn, NotRequired, TypedDict, assert_never, cast
from typing import Any, Literal, NoReturn, NotRequired, TypedDict, cast

from django.conf import settings
from django.contrib.auth.models import AnonymousUser, User
Expand Down Expand Up @@ -249,6 +249,7 @@ def __eq__(self, other: Any) -> bool:
"NotJsonDict",
"NotOK",
"NoSubject",
"TokenExpired",
}

_exception_code: dict[INTROSPECT_ERROR, Literal[401, 503]] = {
Expand All @@ -260,6 +261,7 @@ def __eq__(self, other: Any) -> bool:
"NotAuthorized": 401,
"NotActive": 401,
"NoSubject": 503,
"TokenExpired": 401,
}

def raise_exception(self, method: str, path: str) -> NoReturn:
Expand All @@ -281,7 +283,6 @@ def raise_exception(self, method: str, path: str) -> NoReturn:
raise IntrospectAuthenticationFailed(self)
elif code == 503:
raise IntrospectUnavailable(self)
assert_never(code)

def as_cache_value(self) -> CachedFxaIntrospectResponse:
cached: CachedFxaIntrospectResponse = {"error": self.error}
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ exclude_also = [
"if TYPE_CHECKING:",
# Skip abstract methods
"raise NotImplementedError",
# Skip mypy exhaustion statement
"assert_never\\(.*\\)",
]

[tool.coverage.run]
Expand Down

0 comments on commit e17060f

Please sign in to comment.