Skip to content

Commit 41b3aba

Browse files
oidc: add expiry key to mint_token response (#18238)
Co-authored-by: Facundo Tuesca <[email protected]>
1 parent 6e0a467 commit 41b3aba

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tests/unit/oidc/test_views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ def find_service(iface, **kw):
624624
assert response == {
625625
"success": True,
626626
"token": "raw-macaroon",
627+
"expires": 900,
627628
}
628629

629630
assert oidc_service.verify_jwt_signature.calls == [
@@ -725,6 +726,7 @@ def find_service(iface, **kw):
725726
assert response == {
726727
"success": True,
727728
"token": "raw-macaroon",
729+
"expires": 900,
728730
}
729731

730732
assert oidc_service.verify_jwt_signature.calls == [

warehouse/oidc/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class JsonResponse(TypedDict, total=False):
3939
message: str | None
4040
errors: list[Error] | None
4141
token: StrictStr | None
42+
# This value is used to communicate the minted token's expiration
43+
# time to the user. It is not used to determine the expiration,
44+
# changing this field does not change the token's expiration time.
45+
expires: int | None
4246
success: bool | None
4347

4448

@@ -340,7 +344,7 @@ def mint_token(
340344
metrics = request.find_service(IMetricsService, context=None)
341345
metrics.increment("warehouse.oidc.mint_token.github_reusable_workflow")
342346

343-
return {"success": True, "token": serialized}
347+
return {"success": True, "token": serialized, "expires": expires_at}
344348

345349

346350
def is_from_reusable_workflow(

0 commit comments

Comments
 (0)