I have a Java Backend (with Jersey) and an Angular Client (on a different Host), which accesses the api provides by Jersey.
Without authentication everything works great (I have a CORS filter included).
Now when I add basic auth to web.xml on Java Backend, the problems start.
Sample:
<security-constraint>
<web-resource-collection>
<web-resource-name>Sample</web-resource-name>
<url-pattern>/manager-api/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
<!--<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint> -->
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
I tried to set the Basis Authentication header on every AngularJS $http call. But the problem is, that this header isnt attached to the OPTIONS call, which is made first.
HTTP Sample:
App.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.headers.common['Authorization'] = 'Basic ' + authdata;
}]);
Do you have any idea how I can get arround this? Is there a way to add the header to the options call? Or is it possible to allow OPTIONS calls without allowing GET and POST calls?
Any help is highly appreciated.
Greets Marc