-
Notifications
You must be signed in to change notification settings - Fork 1k
oidc: add expiry key to mint_token response #18238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This allows clients that do TP exchanges to keep track of the short-lived token's expiry without poking through the macaroon's caveats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally okay, one question inline needs to be addressed first.
@@ -39,6 +39,7 @@ class JsonResponse(TypedDict, total=False): | |||
message: str | None | |||
errors: list[Error] | None | |||
token: StrictStr | None | |||
expires: int | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: how can this ever be None
when an OIDC is minting this? If it's None
ever in the context of OIDC exchange, then it would not expire, and that's counter to the Trusted Publishing design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the minting fails, like here:
def _invalid(errors: list[Error], request: Request) -> JsonResponse:
request.response.status = 422
return {
"message": "Token request failed",
"errors": errors,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An easyish workaround to prevent None would be to return -1
or such for the invalid response, and thus prevent accidental non-expiring tokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the response that we send to users after a token is minted. The expiration of the token is set before this, here:
warehouse/warehouse/oidc/views.py
Line 278 in 82e9149
expires_at = not_before + 900 |
The JSON response only communicates this value to the user. If we incorrectly set expires
to None
in the response, the token would still expire at the correct time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that makes more sense. In that case, a comment here would help prevent future confusion as to how that works.
Co-authored-by: Facundo Tuesca <[email protected]>
This allows clients that do TP exchanges to keep
track of the short-lived token's expiry without
poking through the macaroon's caveats.
Closes #18235.