简体   繁体   English

如何在重定向中添加授权 header (Spring Security)

[英]How to add Authorization header in redirect (Spring Security)

I am trying to redirect to a URL after certain checks are passed.通过某些检查后,我试图重定向到 URL。

@GetMapping("/verify")
public void verify(HttpServletResponse response) {
  response.setHeader("Authorization", "bearer ehxxxxxxxx");
  response.sendRedirect("/home");
}

But I am unable to retrieve the Authorization header at JwtAuthenticationFilter .但我无法在 JwtAuthenticationFilter 检索Authorization JwtAuthenticationFilter (Skipping that code, since it works for other requests). (跳过该代码,因为它适用于其他请求)。

What am I doing wrong?我究竟做错了什么? please help.请帮忙。

Try this code:试试这个代码:

@GetMapping("/verify")
public void verify(HttpServletResponse response) {
  response.setHeader("Authorization", "bearer ehxxxxxxxx");
  RequestDispatcher view = request.getRequestDispatcher("/home");
  view.forward(request, response);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring:使用授权标头重定向 - Spring: Redirect with Authorization Header Spring 安全 - 使用授权进行身份验证 Header - Spring Security - Authenticating with Authorization Header 如何修复 Spring 安全授权 header 未通过? - How to fix Spring Security Authorization header not being passed? Spring 安全 5.3.2 OAuth 2,资源所有者密码凭证流程 - 如何将额外的 HEADER 参数添加到授权服务器 uri - Spring Security 5.3.2 OAuth 2, Resource Owner Password Credentials Flow - How to add additional HEADER parameters to authorization server uri Spring security 获取授权 header 值 - Spring security get authorization header value 春季安全许可证全部需要授权标头 - Spring security permitAll requires Authorization header 如何在Spring Security中将未找到标头重定向到登录页面 - How to Redirect Header Not Found Exception to Login Page in Spring Security 如何在 Spring Security 中添加授权过滤器来验证令牌并设置安全上下文? - How to add a authorization filter to validate token and set security context in spring security? 如何将自定义安全标头添加到 spring soap 客户端 - How to add custom security header to spring soap client 如何在spring security中添加所有请求的jwt认证标头? - How to add jwt authendication header with all requests in spring security?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM