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

Preprocess XHR response #19

Open
dylancwood opened this issue Feb 6, 2015 · 0 comments
Open

Preprocess XHR response #19

dylancwood opened this issue Feb 6, 2015 · 0 comments
Labels

Comments

@dylancwood
Copy link

We are in the planning stages of implementing a new authentication scheme based on the HAWK signature authentications scheme. Using the planned scheme, we would need to generate a signature and append it to the AJAX header before each request for a protected resource. This can be accomplished easily enough with the ajaxConfig.beforeSend option 👍

There are at least few scenarios under which the server may fail to authenticate the signature:

  1. The signature is invalid (was hashed using the wrong key/algorithm)
  2. The timestamp sent with the request is out of sync with the server's time

In the first case, we would like to catch the unauthorized response, and present a login-popup for the user to log in and re-generate their private key. Upon successful retrieval of a new key, we would like to resend the request. In the second case, we would like to re-send the request with a modified timestamp to compensate for skew between the client and server time.

How do you recommend handling these unauthorized responses without specifying an error handler for each .fetch, .sync call? Perhaps an ajaxConfig.error callback would allow us to intercept the unauthorized response, make adjustments and retry it.

@bear bear added the question label Feb 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants