我正在构建一个带有Angular前端的restful Web服务。如果用户使用错误的凭据登录,浏览器将自动显示登录弹出窗口。我想通过响应代码403而不是401来阻止这种情况。
我对this question进行了审核,但对我的用例没有帮助。我也尝试过在谷歌上找到不同的解决方案,但在所有情况下都会留下401给登录弹出窗口。
这就是我现在所拥有的,但它不起作用:
SecurityConfig.java:
Exception calling "WriteToServer" with "1" argument(s): "The given value of type String from the data source cannot be converted to
type date of the specified target column."
At C:\powershell_scripts\batch_csv_import-code1-working-test for auto table.ps1:43 char:3
+ $bulkcopy.WriteToServer($datatable)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
340000 rows have been inserted in 00:00:03.5156162
CustomAuthenticationFailureHandler.java:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
//...
@Autowired
CustomAuthenticationFailureHandler authenticationFailureHandler;
//...
@Override
protected void configure(HttpSecurity http) throws Exception {
.formLogin().failureHandler(authenticationFailureHandler).permitAll().and()
//...
.httpBasic()
.and()
.csrf()
.disable();
}
}