SpringSecurity系列之请求防火墙默认已开启

  发布时间:2025-11-05 04:36:12   作者:玩站小弟   我要评论
复制publicclassStrictHttpFirewallimplementsHttpFirewall{ privateSet<String>allowedHtt 。
SpringSecurity系列之请求防火墙默认已开启
系列复制public class StrictHttpFirewall implements HttpFirewall {   private Set<String> allowedHttpMethods = createDefaultAllowedHttpMethods();   private staticSet<String> createDefaultAllowedHttpMethods() {    Set<String> result = new HashSet<>();    result.add(HttpMethod.DELETE.name());    result.add(HttpMethod.GET.name());    result.add(HttpMethod.HEAD.name());    result.add(HttpMethod.OPTIONS.name());    result.add(HttpMethod.PATCH.name());    result.add(HttpMethod.POST.name());    result.add(HttpMethod.PUT.name());    return result;   }   private void rejectForbiddenHttpMethod(HttpServletRequest request) {    if (this.allowedHttpMethods == ALLOW_ANY_HTTP_METHOD) {     return;    }    if (!this.allowedHttpMethods.contains(request.getMethod())) {     throw new RequestRejectedException("The request was rejected because the HTTP method "" +       request.getMethod() +       "" was not included within the whitelist " +       this.allowedHttpMethods);    }   }  }  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.
  • Tag:

相关文章

最新评论