【发布时间】:2023-03-24 13:47:01
【问题描述】:
我在我的项目中使用 Spring Rest 服务。现在我想对其余服务强制执行基本身份验证。我能够进行基本身份验证,但我需要该基本身份验证参数中的用户名。我无法从请求中提取基本身份验证参数。
示例网址:
http://testusername:testpasword@localhost:7001/sampleApp/rest/test.json
验证上述网址后,我的服务类中需要 testusername。
我正在使用 apache LDAP 进行身份验证。所以在我的应用程序中我不会使用spring security。但我的服务类中需要基本的身份验证参数。
我的休息类api:
@RequestMapping(value="/test", method = {RequestMethod.POST,RequestMethod.GET},
headers="Accept=application/xml, application/json")
public String getData() (String userId,HttpServletRequest request) {
return "test";
}
谁能帮帮我?
【问题讨论】:
-
请在询问前使用谷歌 - 众多结果之一:forum.springsource.org/…
-
但我的问题是从服务类中的基本身份验证参数中检索用户名。我能够通过 java 客户端发送基本的身份验证参数。身份验证后,我无法在服务类中提取身份验证参数。
标签: java spring basic-authentication