Skip to content
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

Adds a warning when API keys will expire soon #1086

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

fhats-stripe
Copy link
Contributor

Reviewers

r? @stripe/developer-products
cc @stripe/developer-products

Sorry this one's a bit big. I added a new structure for holding API keys, so there's a couple commits in here that are mostly mechanical changes. Recommend going commit-by-commit to see the juicy stuff.

Summary

This change adds a warning on stderr when the stored API keys will expire soon. When expiration is within 24 hours, the warning will appear on every command. Otherwise, if expiration is within the next two weeks, the warning will appear once every 12 hours.

Here's what it looks like with new keys provisioned today, with expiration times doctored in various ways.

Fresh keys:

image

Expiration set to 2023-06-25:

image

Expiration set to 2023-06-16 (tomorrow):

image

I also started setting the expiration time to reflect the expiration returned in the API call during key transfer rather than guessing at today + 90 days. This allows us to locally store the correct expiration if the validity of these keys ever changes.

Unfortunately the precision of these warnings can be a little bit off depending on the time of day the key was issued since we only store the UTC date right now, rather than a timestamp. As such, it's possible that a key which expires at 23:59:00 UTC on January 2 could start showing a 24-hour warning at 00:00:01 UTC on January 1. I didn't want to change the storage in this PR because I didn't want to expand the scope, but it's something we could probably improve the precision of relatively easily in the future.

@fhats-stripe fhats-stripe requested a review from a team as a code owner June 15, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants