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

[8.x] Add default timeout to NotPwnedVerifier #37440

Merged
merged 1 commit into from
May 21, 2021

Conversation

pgrenaud
Copy link
Contributor

The NotPwnedVerifier makes HTTP request to verify that the given password has not been compromised in public breaches using the Have I Been Pwned public API. Any HTTP request made to an external service can hang for a long time if this service is under heavy load and not responding in a prompt manner. The HTTP request is made using Guzzle, which default to wait indefinitely.

This PR defines a default timeout value of 15 seconds to be use by the NotPwnedVerifier when making HTTP request to the API. The value of 15 seconds is a value that we use in production for some API. We could argue that this value could be higher or lower, and I would happily change it. But I do think that it is important that some timeout value be configured to prevent the request made by the end user from hanging for a long time or reaching PHP's max_execution_time of 30 seconds.

I would like to expose this value to the configuration (it is already configurable by the service provider), but I'm not sure in which configuration file it should be.

Also, I would have like to add a unit test to simulate this exact scenario, but unfortunately, since the request never reaches CURL in the testing environment, the timeout value has no effect.

@GrahamCampbell GrahamCampbell changed the title Add default timeout to NotPwnedVerifier [8.x] Add default timeout to NotPwnedVerifier May 20, 2021
@pgrenaud
Copy link
Contributor Author

@GrahamCampbell Sorry about that! I've made the requested fixes.

@foremtehan
Copy link
Contributor

I think 3 or 5 seconds is appropriate amount of time to wait

@taylorotwell taylorotwell merged commit 3a0af0a into laravel:8.x May 21, 2021
@pgrenaud pgrenaud deleted the notpwnedverifier-timeout branch May 21, 2021 15:09
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.

4 participants