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

Interpret any string in options as an API Key instead of using a regex #660

Merged
merged 2 commits into from
Jul 24, 2019

Conversation

rattrayalex-stripe
Copy link
Contributor

@rattrayalex-stripe rattrayalex-stripe commented Jul 24, 2019

r? @ob-stripe
cc @stripe/api-libraries @jlomas-stripe @paulasjes-stripe @remi-stripe

isAuthKey relies on a regex which assumes a fixed length of a secret key token. This assumption recently broke.

Looking at the code, passing a string which does not fit the regex currently noops completely, so I chose to simply check whether it is a non-empty string and if so, assume it is an auth key.

Note that you could maybe interpret this to be a breaking change, because you could have previously written this:

stripe.customers.retrieve('cus_123', 'garbage');

which would have been equivalent to stripe.customers.retrieve('cus_123') and worked fine, but with this change would fail with a bad secret key.

I think that's fine, but not sure and want to check with others.

Relatedly, I moved isAuthKey from utils but that didn't seem to be publicly exported so I think that's fine.

Copy link
Contributor

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants