Java Spring安全性-authorizerequest()、anyRequest()和authenticated()做什么?
在下面的代码中,不同的链式方法做什么? 公共URL是包含公共URL的字符串数组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
protected void configure(HttpSecurity http ) throws Exception {
http.authorizeRequests()
.antMatchers(PUBLIC_URL).permitAll()
.anyRequest().authenticated();
}
这意味着所有请求都必须经过身份验证,除了那些与
公共URL
允许使用authorizeRequests()
实现基于RequestMatcher
限制访问HttpServletRequest
这将允许公共访问,即任何人都可以访问端点公共URL而无需身份验证permitAll()
将限制除PUBLIC\u URL之外的任何其他端点的访问,并且必须对用户进行身份验证anyRequest().authenticated()