重定向时携带Authorization Base --单点登录接入rabbitmq示例
@IgnoreSecurity
@GetMapping
public void test(HttpServletRequest request, HttpServletResponse response) throws IOException {
String url = "http://192.168.204.28:15672/#/";
//携带Authorization base
String plainCredentials = "username:password";
String base64Credentials = new String(Base64.encodeBase64(plainCredentials.getBytes()));
request.getSession().setAttribute("Authorization", "Basic " + base64Credentials);
response.sendRedirect(url);
}
本文详细介绍了如何在使用Spring MVC的API中,通过Base64编码实现Authorization携带,实现在重定向到RabbitMQ管理界面时进行身份验证。步骤包括设置Session属性和执行安全重定向。
1708

被折叠的 条评论
为什么被折叠?



