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

Start only one login sequence at a time when retrying requests that responded with 401 status code #498

Open
fluiddot opened this issue Apr 25, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@fluiddot
Copy link
Contributor

Expected behavior

When retrying a request due to the response error 401 - Unauthorized (reference), we should ensure that only one login sequence is triggered at a time.

Actual behavior

Currently, we check the value of isAuthenticating for this purpose. However, it's never set to true, and therefore the login sequence can be triggered several times. This might lead to generating a lot of login requests, and in some cases API request blocks due to a high volume of login attempts, if such restrictions are set up in the hosting.

Steps to reproduce the behavior

Preparation:
Reproducing this issue requires modifying somehow the requests to fail with status code 401. This can be achieved by using a proxy, like the Charles proxy app, and rewriting the responses to return the desired status code.

  1. Listen for requests made using CookieNonceAuthenticator and select one endpoint for modifying its response.
    NOTE: Currently, this authenticator is used in WordPress-iOS for requests made to .ORG sites via API rest.
  2. Force the status code response for the selected endpoint to be 401 (this can be achieved with a proxy and bypassing requests).
  3. Trigger multiple requests to the selected endpoint and observe that each one triggers a login sequence (i.e. requests to the login URL).
WordPressKit Environment
  • WordPressKit Version [e.g. 22]: 4.49.0
  • OS: [e.g. iOS 12.1.3 (16D40)] iOS 15.4
  • Device: [e.g. iPhone XS] iPhone 13
  • Xcode Version: [e.g. Xcode 10.1 (10B61)] N/A
Additional Context

More information about this issue can be found in p1650593568370329-slack-C011BKNU1V5.

@fluiddot fluiddot added the bug Something isn't working label Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant