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

[系统运维] 时间:2025-11-05 04:36:37 来源:益强IT技术网 作者:应用开发 点击:82次
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.

(责任编辑:域名)

    相关内容
    精彩推荐
    热门点击
    友情链接