for some time I'm playing around RESTeasy and angularjs $http calls. Idea is to have Web Api that angular web app uses as it's backend, but those calls I'd like to have secured with at least HTTP Basic Authentication only for website, because there won't be any user accounts and so on. What i've managed to do so far is that REST Service works with authentication ("Authorization":"Basic user_pass_Base64_hash" header) when calling it from Poster add-on in mozilla. But problems arrive when I try to connect via angularjs $http. Here is a code of angular call:
$http({
url:'http://serverurl/rest/anouncements/announce/1',
method: 'GET',
headers: {'Authorization':'Basic someBase64Hash'}
})
.success(function(data){
// do something with data
}) ;
Via Servlet filter I modify response by adding those headers:
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.addHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Content-Length");
and checking if user:password decoded from hash exists in database.
I don't really know what else can I do make it work, I already tried many things I've read about in other posts or in docs. Could please anyone help? Resteasy version is 2.2.3 and angular 1.2.10.
Thanks, Michal