I managed to successfully invoke a URL behind a directory in Apache that is protected with Basic Authentication (htpasswd, etc.). The Ajax GET request works normally and returns the protected content:
var encoded = Base64.encode(username + ':' + password);
$.ajax({
url: "/app/test",
type: "GET",
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'Basic ' + encoded);
},
success: function() {
window.location.href = '/app/test.html';
}
});
My original assumption was that once the web session had successfully authorized a request, it would make possible the redirection in the 'success' block without asking user credentials. When this code block is invoked, the user had entered username and password, in a non-protected environment. However, when the redirect is invoked, the browser will popup the the login/password window.
Any suggestions on how I could pre-authorize a session with the Basic Authorization which would have been provided by the users?