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

Update basic auth cache to key off of origin instead of url #13281

Merged
merged 4 commits into from Sep 16, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

added test that verifies proper basic auth caching behavior

  • Loading branch information
gilbertw1 committed Sep 16, 2016
commit 712b1d5ea0eb9625a9e868673bc9d172f84b9ada
"url": "/dom/lists/DOMTokenList-Iterable.html"
}
]
},
"reftest": {
"http/basic-auth-cache-test.html": [
{
"path": "http/basic-auth-cache-test.html",
"references": [
[
"/http/basic-auth-cache-test-ref.html",
"=="
]
],
"url": "/http/basic-auth-cache-test.html"
}
]
}
},
"reftest_nodes": {}
"reftest_nodes": {
"http/reftest-basic-auth-cache-test.html": [
{
"path": "http/basic-auth-cache-test.html",
"references": [
[
"/http/basic-auth-cache-test-ref.html",
"=="
]
],
"url": "/http/basic-auth-cache-test.html"
}
]
}
},
"reftest_nodes": {
"2dcontext/building-paths/canvas_complexshapes_arcto_001.htm": [
@@ -0,0 +1,6 @@
<!doctype html>
<meta charset="utf-8">
<html>
<img src="resources/image.png">
<img src="resources/image.png">
</html>
@@ -0,0 +1,15 @@
<!doctype html>
<meta charset="utf-8">
<link rel="match" href="basic-auth-cache-test-ref.html">

This comment has been minimized.

@jdm

jdm Sep 16, 2016

Member

Oh, these elements should be children of the <html> element.

This comment has been minimized.

@gilbertw1

gilbertw1 Sep 16, 2016

Author Contributor

ah right, fixed.

<html>
<div id="auth"> </div>
<div id="noauth"> </div>
<script type="text/javascript">
var authImg = '<img src="http://testuser:testpass@' + window.location.host + '/http/resources/securedimage.py">';
document.getElementById('auth').innerHTML = authImg;
setTimeout(function() {

This comment has been minimized.

@jdm

jdm Sep 15, 2016

Member

Rather than a timeout (which could cause intermittent failures if the first image finishes loading before the timeout fires), we should:

  • add class="reftest-wait" to the <html> element
  • add an onload handler to the first image, which starts the second image load
  • add an onload handler to the second load which removes the reftest-wait class

This comment has been minimized.

@gilbertw1

gilbertw1 Sep 15, 2016

Author Contributor

Thanks for the feedback! I've just incorporated the test changes in a new commit.

var noAuthImg = '<img src="http://' + window.location.host + '/http/resources/securedimage.py">';
document.getElementById('noauth').innerHTML = noAuthImg;
}, 100);
</script>
</html>
Binary file not shown.
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -

def main(request, response):
image_url = str.replace(request.url, "securedimage.py", "image.png")

if "authorization" not in request.headers:
response.status = 401
response.headers.set("WWW-Authenticate", "Basic")
return response
else:
auth = request.headers.get("Authorization")
if auth != "Basic dGVzdHVzZXI6dGVzdHBhc3M=":
response.set_error(403, "Invalid username or password - " + auth)
return response

response.status = 301
response.headers.set("Location", image_url)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.