忽略某些URL路径,Spring Security

时间:2018-08-21 12:00:03

标签: java spring spring-security

我想禁用Spring(或我)为“ / login” URL提供的所有过滤器。我已经编写了这段代码,但是Spring似乎忽略了这些代码行。我在做什么错了?

 @Override
protected void configure(HttpSecurity http) throws Exception {
    http
            .csrf().disable()
            .cors()
            .and().exceptionHandling().authenticationEntryPoint(authenticationEntryPoint)
        .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and().authorizeRequests()
            .antMatchers(HttpMethod.GET, AUTH_WHITELIST).permitAll()
            .antMatchers("/admin").hasAuthority("ADMIN")
            .anyRequest().authenticated()
            .and().requestCache().disable()
            .logout().and().rememberMe().disable()
            .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);

}

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("/login");
}

1 个答案:

答案 0 :(得分:0)

您需要在httpSecurity中指定登录表单的位置,尝试类似的操作

<button class="dropdown-btn" (click)="togg();"> Besics</button>
    <div *ngIf="!toggle_menu1">
    <a routerLink="/imp-style"> Implimenting Style  </a>
    </div>
<button class="dropdown-btn" (click)="togg();">Image</button>
    <div *ngIf="!toggle_menu2">
    <a routerLink="/slider"> Image Slider</a>
    </div>
<button class="dropdown-btn" (click)="togg();">Forms</button>
    <div *ngIf="!toggle_menu3">
    <a routerLink="/signup"> Signup </a>
    <a routerLink="/signup"> Login </a>
    <a routerLink="/signup"> Register </a>
    </div>
<button class="dropdown-btn" (click)="togg();">Service</button>
    <div *ngIf="!toggle_menu4">
    <a routerLink="/dipika-task"> Data Display </a>
    <a routerLink="/social-media"> Social Media </a>
    <a routerLink="/student"> Student </a>
    </div>