首页 > 解决方案 > 如何在 Spring OAuth2 中配置未经授权的端点

问题描述

假设我在http://localhost:8080/
上启动了服务器,我该 如何配置以跳过http://localhost:8080/aaaa上的授权

标签: springspring-bootspring-securityspring-security-oauth2

解决方案


@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(final HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
            .antMatchers("/aaaa").permitAll()
            .anyRequest().authenticated();
    }
}

推荐阅读