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
add auth cache to resources + set auth header from it if url does not have creds #10111
Conversation
This is a great start! Please be sure to:
The biggest issue to address here is that the cache needs to support more than a single entry. We actually want a hashmap of serialized URLs to username/password credentials, so we can easily determine if we have stored credentials for a given URL or not. Additionally, we should write a unit test that demonstrates that this new code works as expected - the ones in |
Still need to fix the http_loader unit test stuff(it's failing because a lot of functions argument number increased by 1) as well as add a test. Hoping I could get some comments if I am on the right track on the other stuff though. Thanks! |
Definitely on the right track! Reviewed 2 of 2 files at r2. components/net/http_loader.rs, line 558 [r2] (raw file): components/net/http_loader.rs, line 560 [r2] (raw file): components/net/http_loader.rs, line 563 [r2] (raw file): components/net/http_loader.rs, line 564 [r2] (raw file): components/net/http_loader.rs, line 565 [r2] (raw file): if let Some(ref auth_entry) = auth_cache.read().unwrap().get(url) {
auth_from_entry(&auth_entry, headers);
} components/net/http_loader.rs, line 573 [r2] (raw file): components/net/http_loader.rs, line 577 [r2] (raw file): headers.set(Authorization(Basic { username: user_name, password: password })); components/net/resource_thread.rs, line 277 [r2] (raw file): Comments from the review on Reviewable.io |
Great work! Still looking for a unit test that shows the changes working, and Reviewed 3 of 3 files at r3. Comments from the review on Reviewable.io |
added a unit test and tidied up |
Great! There are a couple small changes left, but you can squash everything together once they're complete. Reviewed 2 of 2 files at r4. components/net/resource_thread.rs, line 277 [r4] (raw file): tests/unit/net/http_loader.rs, line 1486 [r4] (raw file): AuthCacheEntry {
user_name: "username".to_owned(),
password: "test".to_owned(),
} tests/unit/net/http_loader.rs, line 1492 [r4] (raw file): tests/unit/net/http_loader.rs, line 1494 [r4] (raw file): Comments from the review on Reviewable.io |
@bors-servo: r+ Reviewed 2 of 2 files at r5. Comments from the review on Reviewable.io |
📌 Commit d49d3b0 has been approved by |
add auth cache to resources + set auth header from it if url does not have creds initial attempt of - in resource_thread.rs, define an HTTP authorization cache storage (username, password, URL) and instantiate it like the cookie_storage member (inside an Arc<Rwlock<>> value, to enable sharing it between threads) - in modify_request_headers in http_loader.rs, implement the remaining pieces of step 12(13?) of the appropriate specification using this new authorization cache. for the NCSU student project Implement HTTP authorization UI and persistent sessions. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10111) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor |
initial attempt of
in resource_thread.rs, define an HTTP authorization cache storage (username, password, URL) and instantiate it like the cookie_storage member (inside an Arc<Rwlock<>> value, to enable sharing it between threads)
in modify_request_headers in http_loader.rs, implement the remaining pieces of step 12(13?) of the appropriate specification using this new authorization cache.
for the NCSU student project Implement HTTP authorization UI and persistent sessions.
This change is