针对不同端口的HttpSecurity antMatchers

时间:2015-09-02 10:00:58

标签: java spring spring-security spring-boot

我有一个带有执行器和安全启动器依赖关系的Spring-Boot应用程序 我想用HTTP-basic-auth保护执行器端点 如果mangagment.port是默认代码,则以下代码按预期工作 但我想将此属性设置为mangagment.port=9000

@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/admin/**").fullyAuthenticated()
                .and()
                .httpBasic()
                .and()
                .csrf().disable();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser("user").password("4321").roles("USER", "ADMIN");
    }
}

如何保护不同的端口?

我是否必须使用端口映射器,如果是这样,是否有任何安全问题?

.portMapper()
      .http(9090).mapsTo(9443)
      .http(80).mapsTo(443);

0 个答案:

没有答案
相关问题