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

Don't ask user to authenticate if WWW-Authenticate header is not provided #357

Closed

Conversation

vicr123
Copy link
Contributor

@vicr123 vicr123 commented Jul 2, 2024

Currently, when a 401 response is received from the server, a routine is run that checks some items and attempts to re-issue a request with authentication headers. When this is returned to a call to fetch() this makes Ladybird constantly reissue the same request over and over again.

This PR ensures that the re-request logic is only engaged when the WWW-Authenticate header is present, allowing the client JS to handle a 401 from the server as needed.

@ladybird-bot
Copy link
Collaborator

Hello!

One or more of the commit messages in this PR do not match the Ladybird code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why.
Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.

@vicr123 vicr123 force-pushed the features/401-www-authenticate branch from 362627d to f6c5560 Compare July 2, 2024 08:50
@circl-lastname
Copy link
Contributor

You have edited a spec comment so that it doesn't match the spec anymore. (https://fetch.spec.whatwg.org/#concept-http-network-or-cache-fetch) Was that intended?

Comment on lines 1903 to 1904
// 14. If response’s status is 401, httpRequest’s response tainting is not "cors", includeCredentials is true,
// and request’s window is an environment settings object, then:
// request’s window is an environment settings object, and there is a WWW-Authenticate header, then:
Copy link
Member

Choose a reason for hiding this comment

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

This comment is copied verbatim from the Fetch specification at https://fetch.spec.whatwg.org/#concept-http-network-or-cache-fetch

If this step in the spec is incorrect, please file a bug against https://github.com/whatwg/fetch

If we need to do something differently here (because the spec is wrong), we can add a separate comment, something like:

// FIXME: This isn't in the spec, but is actually required to avoid getting into a request loop.
//        Spec bug: https://github.com/whatwg/fetch/issues/...

@vicr123
Copy link
Contributor Author

vicr123 commented Jul 2, 2024

Agh, I didn't realise it was coped verbatim from the spec. Could this behaviour be part of 14.1? (Needs testing: WWW-Authenticate missing)

@awesomekling
Copy link
Member

Agh, I didn't realise it was coped verbatim from the spec. Could this behaviour be part of 14.1? (Needs testing: WWW-Authenticate missing)

Perhaps it could! I'm not sure.

cc @Lubrsi, I think you've looked at this in the past?

@vicr123 vicr123 force-pushed the features/401-www-authenticate branch from f6c5560 to a1051a3 Compare July 2, 2024 09:32
If the WWW-Authenticate header is not provided, the authentication
prompt is skipped
@vicr123
Copy link
Contributor Author

vicr123 commented Aug 13, 2024

Superseded by #1056

@vicr123 vicr123 closed this Aug 13, 2024
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