Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring安全性-authorizerequest()、anyRequest()和authenticated()做什么?_Java_Spring_Spring Boot_Rest_Spring Security - Fatal编程技术网

Java Spring安全性-authorizerequest()、anyRequest()和authenticated()做什么?

Java Spring安全性-authorizerequest()、anyRequest()和authenticated()做什么?,java,spring,spring-boot,rest,spring-security,Java,Spring,Spring Boot,Rest,Spring Security,在下面的代码中,不同的链式方法做什么? 公共URL是包含公共URL的字符串数组 protected void configure(HttpSecurity http ) throws Exception { http.authorizeRequests() .antMatchers(PUBLIC_URL).permitAll() .anyRequest().authenticated(); } 这意味着所有请求都必须经过身份验证,除了那些与公共URL

在下面的代码中,不同的链式方法做什么? 公共URL是包含公共URL的字符串数组

protected void configure(HttpSecurity http ) throws Exception {

    http.authorizeRequests()
        .antMatchers(PUBLIC_URL).permitAll()
        .anyRequest().authenticated();

}

这意味着所有请求都必须经过身份验证,除了那些与
公共URL

  • authorizeRequests()
    允许使用
    RequestMatcher
    实现基于
    HttpServletRequest
    限制访问

  • permitAll()
    这将允许公共访问,即任何人都可以访问端点公共URL而无需身份验证

  • anyRequest().authenticated()
    将限制除PUBLIC\u URL之外的任何其他端点的访问,并且必须对用户进行身份验证

我们还可以根据权限配置访问,可以管理会话、HTTPS通道等等。您可以从中找到更多详细信息