$http角度请求如何通过 Spring 引导安全检查



我正在通读本教程:

https://spring.io/guides/tutorials/spring-security-and-angular-js/

在作者证明这不起作用的点上:

$ curl localhost:8080/resource
{"timestamp":1420442772928,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/resource"}

在以下部分中,作者生成了以下代码片段:

    angular.module('hello', [])
      .controller('home', function($http) {
      var self = this;
      $http.get('/resource/').then(function(response) {
        self.greeting = response.data;
      })
    });

并说这能够获取数据。 我的问题是该片段如何通过安全检查?

TIA,奥莱

我再次阅读它,意识到它使用基本身份验证。 Spring 引导使用用户user和密码打印在控制台上,或者在src/main/resources/application.properties中配置了security.user.password=password条目。

最新更新