Java 我将基本身份验证放在spring boot中,但是我们如何在没有身份验证登录的情况下访问一些Api呢
根据标题,我在SpringBoot中加入了一些基本的身份验证,但是我们如何在没有身份验证登录的情况下访问一些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(); } 我们可
@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();
注意:需要考虑订购