Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/oidcop/client_authn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from oidcop.exception import InvalidClient
from oidcop.exception import MultipleUsage
from oidcop.exception import NotForMe
from oidcop.exception import ToOld
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does It mean tooOld?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, ToOld is correct.

from oidcop.exception import UnknownClient
from oidcop.util import importer

Expand Down Expand Up @@ -409,6 +410,8 @@ def verify_client(
try:
# get_client_id_from_token is a callback... Do not abuse for code readability.
auth_info["client_id"] = get_client_id_from_token(endpoint_context, _token, request)
except ToOld:
raise ValueError("Expired token")
except KeyError:
raise ValueError("Unknown token")

Expand Down
21 changes: 21 additions & 0 deletions tests/test_26_oidc_userinfo_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,27 @@ def test_invalid_token(self):
assert isinstance(args, ResponseMessage)
assert args["error_description"] == "Invalid Token"

def test_expired_token(self, monkeypatch):
_auth_req = AUTH_REQ.copy()
_auth_req["scope"] = ["openid", "research_and_scholarship"]

session_id = self._create_session(_auth_req)
grant = self.session_manager[session_id]
access_token = self._mint_token("access_token", grant, session_id)

http_info = {"headers": {"authorization": "Bearer {}".format(access_token.value)}}

def mock():
return time_sans_frac() + access_token.expires_at + 1

monkeypatch.setattr("oidcop.token.time_sans_frac", mock)

_req = self.endpoint.parse_request({}, http_info=http_info)

assert _req.to_dict() == {
"error": "invalid_token", "error_description": "Expired token"
}

def test_userinfo_claims(self):
_acr = "https://refeds.org/profile/mfa"
_auth_req = AUTH_REQ.copy()
Expand Down