Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

woodruffw
Copy link
Member

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.

This allows clients that do TP exchanges to keep
track of the short-lived token's expiry without
poking through the macaroon's caveats.
Copy link
Member

@miketheman miketheman left a 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
Copy link
Member

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.

Copy link
Contributor

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,
    }

Copy link
Member

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.

Copy link
Contributor

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:

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.

Copy link
Member

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trusted Publishing: include an expiration key in the mint-token response?
4 participants