title: Send User and Password of Spring security in Ajax (jquery) with basic authentication
body: <p>I have a webservice which requires a basic authentication to access it. Then I have a Web Service Client, which is in spring (mvc, security, etc). From the client application, I make an ajax request (jquery) to my webservice, the query is basically as follows:</p>
  
  <pre><code>$.ajax
  ({
    type: "GET",
    url: "index1.php",
    dataType: 'json',
    async: false,
    headers: {
      "Authorization": "Basic " + btoa(USERNAME + ":" + PASSWORD)
    },
    data: '{ "comment" }',
    success: function (){
      alert('Thanks for your comment!'); 
    }
  });
  </code></pre>
  
  <p>For this I have to expose the text of the username and password. For both applications I drive the same users. my question is, is there a way to intercept the request and put the values ​​of username and password of the spring session security ?. This in order not to expose the password in the javascript file, but at the same time to send the authentication webservice.</p>