Spring boot - return 403 Forbidden instead of redirect to login page
<p>In Spring Boot web application I have a following security configuration:</p>

<pre><code>@Override
public void configure(HttpSecurity http) throws Exception {
    // @formatter:off   
    http
        .headers().frameOptions().disable()
        .and()
            .antMatcher("/**").authorizeRequests()
            .antMatchers("/actuator/health").permitAll()
            .antMatchers("/actuator/**").hasAuthority(Authority.Type.ROLE_ADMIN.getName())
            .antMatchers("/login/**").permitAll()
            .anyRequest().authenticated()
        .and()
            .formLogin()
                .loginPage("/login")
                .loginProcessingUrl("/login")
                .failureUrl("/login?error").permitAll()
        .and()
            .logout()
            .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
            .logoutSuccessUrl("/login?logout")
        .and()
            .csrf().csrfTokenRepository(csrfTokenRepository())
        .and()
            .addFilterAfter(csrfHeaderFilter(), CsrfFilter.class)
            .addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class);
    // @formatter:on
}
</code></pre>

<p>Right now, when I'm trying to access for example following url: <code>/api/v1.0/user</code> it redirects me to <code>/api/login</code> page.</p>

<p>How to configure this in order to return <code>403 Forbidden</code> instead of redirect to login page ?</p>