Hey everyone,
I am working on a webpage that will show my Kibana dashboard in an iframe, and I want to send a preflight AJAX request to login to the dashboard before setting the iframe's source. I have been following several posts on here that discuss this, but unfortunately I can't get my code to work. I am working with Kibana 6.8. Please excuse my ignorance, as I am somewhat new to web development.
On document.ready, I run an AJAX POST request that looks like this:
$.ajax({
type: "POST",
xhrFields: {
withCredentials: true
},
data: "test",
contentType: "application/x-www-form-urlencoded",
crossDomain: true,
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', btoa("username" + ":" + "password"));
},
headers: {
'Access-Control-Allow-Credentials' : true,
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS, PUT, PATCH, DELETE',
'Access-Control-Allow-Headers': 'X-Requested-With,content-type,Authorization',
},
url: "/api/security/v1/login",
dataType: "json",
success: ajaxSuccess,
error: ajaxError
});
When this request runs, I get a 401 Unauthorized error. I have double checked to make sure that I'm not passing an incorrect username or password. If anyone could help me on this I would really appreciate it, as I am currently stuck.