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

Use of WWW-Authenticate #20

Open
geoffyoungs opened this issue Jun 9, 2021 · 0 comments
Open

Use of WWW-Authenticate #20

geoffyoungs opened this issue Jun 9, 2021 · 0 comments

Comments

@geoffyoungs
Copy link

I really like the ability to redirect/prompt users to login, in response to a 401, but I'm concerned that the current usage of WWW-Authenticate here is non-standard - ie. the syntax doesn't match & the scheme is not IANA registered: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate#syntax (cf. https://datatracker.ietf.org/doc/html/rfc7235#section-4.1) and wouldn't work if a browser requested the same URL.

In terms of support, I'd personally be tempted to use the non-standard Refresh header to perform the same function? It's also non-standard, but it would mean that the behaviour matched for both normal browser fetches and also responses to FetchRequest().

https://github.com/rails/request.js/blob/main/src/fetch_response.js#L19
e.g.

  get authenticationURL () {
     const refresh = this.response.headers.get('Refresh');

     if (refresh === null) return;

     let bits = refresh.split(/; */), i;

     for (i = 0; i < bits.length; i++) {
       if (bits[i].slice(0,4).toLowerCase() === 'url=') {
         return bits[i].slice(4);
       }
     }
  }
@marcelolx marcelolx self-assigned this Jul 11, 2021
@marcelolx marcelolx removed their assignment Nov 29, 2021
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

No branches or pull requests

2 participants