Missing authentication credentials for REST request

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
Changed password for user apm_system
PASSWORD apm_system = KXCtBDwpm9ARMEpHBBr7

Changed password for user kibana_system
PASSWORD kibana_system = RF3Z7WfP05Iz4UqaQwv6

Changed password for user kibana
PASSWORD kibana = RF3Z7WfP05Iz4UqaQwv6

Changed password for user logstash_system
PASSWORD logstash_system = RMUY26uScdJoc1FwerXc

Changed password for user beats_system
PASSWORD beats_system = QTpFzdVUT8e7cna7y3z7

Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = 89npTHP9Qt3NAUCuUNq9

Changed password for user elastic
PASSWORD elastic = x45gqZbnXlxSzxoOrXfd
 $.ajax({
        timeout		: 10000
        ,cache 		: true
        ,async 		: false
        ,dataType   : "json"
        ,type		: "POST"
        ,contentType: 'application/json'
        ,url		: 'http://localhost:9200/_search'
        ,data       : params
        ,success : function(data, status, xhr){
            if(callbackFn) {
                callbackFn(data, callbackParam || '');
            }
        }
        ,error	: function(xhr,status,error){
            console.log(url, xhr);
            console.log(error);
        }
    });

then.....

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/test_index/_search]

I want to know how to call Ajax after applying security to ElasticSearch. What am I supposed to do??

$.ajax({
        timeout		: 10000
        ,cache 		: true
        ,async 		: false
        ,dataType   : "json"
        ,type		: "POST"
        ,headers: {
            'Authorization': 'Basic ' + btoa('elastic :x45gqZbnXlxSzxoOrXfd')
        }
        ,contentType: 'application/json'
        ,url		: 'http://localhost:9200/_search/'
        ,data       : params
        ,success : function(data, status, xhr){
            if(callbackFn) {
                callbackFn(data, callbackParam || '');
            }
        }
        ,error	: function(xhr,status,error){
            console.log(url, xhr);
            console.log(error);
        }
    });
DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:9200/test_index/_search?pretty'.
    at Object.send (https://code.jquery.com/jquery-3.4.1.js:9837:10)
    at Function.ajax (https://code.jquery.com/jquery-3.4.1.js:9434:15)
    at jsonAjax (http://localhost:8080/resources/common/js/common.js:160:7)
    at getListPage (http://localhost:8080/resources/common/js/common.js:111:9)
    at Object.init (http://localhost:8080/resources/common/js/common.js:133:17)
    at http://localhost:8080/tables:169:30

not working..... please help...

I have solved.

elasticsearch.yml

add

http.cors.allow-headers: "Authorization, X-Requested-With, Content-Type, Content-Length"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.