4

I have secured static resources (css, js, png, htmls, ...) I use basic authentication. The user can't get anything unless he is authenticated.

My question : is there any way to create a form and use javascript to set the value of basic auth for the browser ?

Where does the browser store this header (Authorization = Basic username:password) ?

Something like :

$ajax({
     'beforeSend': function(xhr) {
                xhr.setRequestHeader("Authorization", "Basic " + btoa($("#user").val() + ":" + $("#pass").val()))
            }
)}

works for ajax calls but not for static resources requests !!

nanofarad
  • 40,330
  • 4
  • 86
  • 117
  • Why u want to authenticate via javascript. Is isn't secure and if you are going to make it insecure whats the fun having shiro in place. Default process is that when basic auth is required browsers pop a window asking for username and password that's the way it should work. – Dev May 31 '16 at 04:32
  • I do what the client wants ... – bilal bilal May 31 '16 at 08:28

0 Answers0