我正在试图为我的Spring应用程序实现一个REST API。由于有些资源可能无法被每个人访问,我需要一个安全层。用Spring Security保护REST API
在我已经使用Spring安全(这工作完全正常)为确保我的web应用程序这个应用程序。
我已经添加了以下http
配置到我的spring-security.xml
:
<http pattern = "/api/**" use-expressions = "true" disable-url-rewriting = "true">
<http-basic />
</http>
所以我认为这是开始api/
网址的所有请求将被保护。
问题是,我可以访问我的固定方法没有任何认证。但是,如果使用REST客户端来访问它,我收到此错误:
message: Full authentication is required to access this resource
description: This request requires HTTP authentication.
我不知道如何着手。使用Spring Security来保护REST API的最佳方式是什么?
如何访问您的安全方法,你说你看到他们没有身份验证?通过浏览器?您是否已登录浏览器并登录了用户? – nobeh