Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.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 boot中,但是我们如何在没有身份验证登录的情况下访问一些Api呢_Java_Spring_Spring Boot - Fatal编程技术网

Java 我将基本身份验证放在spring boot中,但是我们如何在没有身份验证登录的情况下访问一些Api呢

Java 我将基本身份验证放在spring boot中,但是我们如何在没有身份验证登录的情况下访问一些Api呢,java,spring,spring-boot,Java,Spring,Spring Boot,根据标题,我在SpringBoot中加入了一些基本的身份验证,但是我们如何在没有身份验证登录的情况下访问一些API呢 @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .anyRequest() .authenticated() .and() .httpBasic(); } 我们可

根据标题,我在SpringBoot中加入了一些基本的身份验证,但是我们如何在没有身份验证登录的情况下访问一些API呢

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
      .authorizeRequests()
      .anyRequest()
      .authenticated()
      .and()
      .httpBasic();
}
我们可以像上面那样忽略特定的URL路径

退房

我们可以像上面那样忽略特定的URL路径


签出。

过滤掉API并允许所有API无需验证

范例

.antMatchers(GET,“/home”,“/health”).permitAll()

这将允许在2个端点上获取所有请求的请求,即使没有身份验证

完整样本

   http
        .authorizeRequests()
        .antMatchers(GET, "/home","/health").permitAll()
        .anyRequest()
        .authenticated()
        .and()
        .httpBasic();

注意:需要订购才能考虑

过滤掉API并允许所有API无需验证

范例

.antMatchers(GET,“/home”,“/health”).permitAll()

这将允许在2个端点上获取所有请求的请求,即使没有身份验证

完整样本

   http
        .authorizeRequests()
        .antMatchers(GET, "/home","/health").permitAll()
        .anyRequest()
        .authenticated()
        .and()
        .httpBasic();
注意:需要考虑订购