How to proper authenticate an AngularJS client to the server

后端 未结 1 1641
猫巷女王i
猫巷女王i 2021-02-02 15:53

I\'m building an AngularJS web-app that uses a RESTful API (Jersey).

On the server side I am using a Java Application Server (in detail Glassfish 4).

My setup is

相关标签:
1条回答
  • 2021-02-02 16:22

    Thanks to the tip of lossleader I solved the problem. I removed the login() method, because I want the Java EE-Server to take care of authentication.

    To access secured areas the AngularJS webapp has to set the HTTP-Header correctly. In my case $http.defaults.headers.common['Authorization'] = 'Basic '; where username:password has to be Base64 encoded.

    After I set the headers correctly, no Password Prompt is shown and the AngularJS webapp can access the REST API.

    0 讨论(0)
提交回复
热议问题