获取基本身份验证标头Spring Boot

时间:2014-06-09 08:59:03

标签: spring spring-boot

我正在使用Spring启动为我的应用程序使用基本身份验证为其余api。

我想获取正在验证的请求的用户名和密码,以执行更细粒度的授权任务。如何处理HttpHeaders以获取详细信息?

1 个答案:

答案 0 :(得分:0)

您可以使用@AuthenticationPrincipal注释将登录用户作为控制器功能的参数。

@RequestMapping(method = RequestMethod.GET, consumes="application/json")
public ResponseEntity<> searchMeta(@AuthenticationPrincipal UserModel activeUser) {
//Do your processing with the UserModel
}
相关问题