如何调整spring引导安全配置?
我启用了spring引导安全性,并将一些URL添加到排除列表(porperty security.ignored) 在application.yaml中 现在,我想在我的配置类中以编程方式向排除列表添加一些新URL 我怎样才能做到这一点如何调整spring引导安全配置?,spring,spring-boot,spring-security,Spring,Spring Boot,Spring Security,我启用了spring引导安全性,并将一些URL添加到排除列表(porperty security.ignored) 在application.yaml中 现在,我想在我的配置类中以编程方式向排除列表添加一些新URL 我怎样才能做到这一点 PS我不能编辑yaml,我只能编辑配置类 如果希望排除java中的某些url模式,而不是yaml或属性 例如: 如果需要排除 @Override protected void configure(HttpSecurity http) throws Excepti
PS我不能编辑yaml,我只能编辑配置类 如果希望排除java中的某些url模式,而不是yaml或属性 例如: 如果需要排除
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/login**").permitAll()
.antMatchers("/admin/**").access("hasRole('ROLE_ADMIN')")
.antMatchers("/**").access("hasRole('ROLE_USER')")
.and()
.formLogin().loginPage("/login").failureUrl("/login?error")
.usernameParameter("username").passwordParameter("password")
.and()
.logout().logoutSuccessUrl("/login?logout")
.and()
.exceptionHandling().accessDeniedPage("/403")
.and()
.csrf();
}
如果你需要忽略
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/authFailure");
}
希望这是有用的。您似乎不理解我写的内容:我想编辑yaml中定义的property security.config。再一次。我不想覆盖它,只需添加到现有的yamlyou说的无法编辑yaml。您需要在application.yaml中完成此操作?属性已在yaml中定义。我只需要修改代码。不要重写,只需通过添加值来更改具体哪个值?理想情况下,Spring Security将自动配置。如果需要排除或忽略任何URL模式,则需要覆盖HttpSecurity或WebSecurity。@Mebin Joe,我明白了。我认为这个问题令人困惑,因为他说他不能编辑yaml,但希望在yaml中配置它。实际上,您可以通过使用web.ignering.antmatchers进行重写方法configure以编程方式忽略URL。。。。。。。