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

API key validation #1520

Merged
merged 1 commit into from
Feb 22, 2019
Merged

API key validation #1520

merged 1 commit into from
Feb 22, 2019

Conversation

ob-stripe
Copy link
Contributor

@ob-stripe ob-stripe commented Feb 17, 2019

r? @remi-stripe

Validates API keys that are passed to StripeConfiguration.ApiKey = key;, new SomeService(key) and new RequestOptions { ApiKey = key }. If the key contains invalid characters (anything other than alphanumeric characters or underscores), an exception is raised.

Partially fixes #1507.

@remi-stripe
Copy link
Contributor

@ob-stripe I don't think we should limit to alphanumeric and underscore. The current ongoing project internally actively considered adding a dash or another character to the API key. We ended up not doing it, but we might in the future and we don't want stripe-dotnet to be extremely strict on that front.

@ob-stripe
Copy link
Contributor Author

I've updated the validation to only check for whitespace characters. ptal @remi-stripe

@ob-stripe ob-stripe assigned remi-stripe and unassigned ob-stripe Feb 17, 2019
Copy link
Contributor

@remi-stripe remi-stripe left a comment

Choose a reason for hiding this comment

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

Minor comments but feel free to self-approve/merge

src/Stripe.net/Infrastructure/StringUtils.cs Outdated Show resolved Hide resolved
src/Stripe.net/Infrastructure/StringUtils.cs Outdated Show resolved Hide resolved
@remi-stripe
Copy link
Contributor

@ob-stripe Added a comment, feel free to self-approve

@ob-stripe ob-stripe force-pushed the integration-v23 branch 2 times, most recently from 5a3595f to 130a982 Compare February 20, 2019 10:41
@ob-stripe ob-stripe force-pushed the ob-validate-api-key branch 3 times, most recently from bb4cef5 to 6ea5e97 Compare February 21, 2019 21:29
@ob-stripe
Copy link
Contributor Author

@remi-stripe Sorry for the back and forth here, but mind taking another look at this PR? I've updated it to be consistent with what we do in stripe-ruby (https://github.com/stripe/stripe-ruby/blob/65cc6998329cfff8c7ae3df1090116fd6764699a/lib/stripe/stripe_client.rb#L236-L251). I think it's better this way since we only need to check the key in one place.

@ob-stripe ob-stripe assigned remi-stripe and unassigned ob-stripe Feb 21, 2019
@ob-stripe ob-stripe mentioned this pull request Feb 21, 2019
52 tasks
@remi-stripe remi-stripe assigned ob-stripe and unassigned remi-stripe Feb 22, 2019
@ob-stripe ob-stripe merged commit cec3d24 into integration-v23 Feb 22, 2019
@ob-stripe ob-stripe deleted the ob-validate-api-key branch February 22, 2019 10:16
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.

2 participants