【发布时间】:2021-08-05 07:29:56
【问题描述】:
目前我正在使用 Vaadin 21,尤其是更好地集成 Spring Security。 我遵循了 Vaadin 21 的 Spring 安全教程并在 https://vaadin.com/docs/latest/flow/integrations/spring/view-based-access-control 上进行操作。但是我需要将 defaultSuccesUrl/successUrl 从“”更改为“/application”,因为目前登录后我总是会被路由到不存在的“/”。我已经玩了很多,但我没有成功。
这是我的安全配置的配置方法:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.rememberMe().alwaysRemember(false);
// Current
http.authorizeRequests().antMatchers("/VAADIN/**").permitAll();
http.authorizeRequests().antMatchers("/services/**").permitAll();
// Set the login processing url
http.formLogin().loginProcessingUrl(ApplicationUrl.APP_LOGIN_PROCESSING_URL);
// Set the default success Url
http.formLogin().defaultSuccessUrl(ApplicationUrl.APP);
// Set the default failure Url
http.formLogin().failureUrl(ApplicationUrl.APP_LOGIN_FAILURE_URL);
super.configure(http);
// This is important to register your login view to the
// view access checker mechanism:
setLoginView(http, LoginView.class);
}
我已经把 http.formLogin().loginProcessingUrl(ApplicationUrl.APP_LOGIN_PROCESSING_URL); super.configure(http) 后改为 http.formLogin().successForwardUrl(ApplicationUrl.APP);但没有任何效果。
希望有人能给我一个提示如何解决这个问题。在 Vaadin 14 中这没有问题,因为在那里,您必须“手动”配置它。
谢谢, 弗洛里安
【问题讨论】:
-
不是问题的解决方案,但您应该为 / 配置一个指向 /application 的 RouteAlias。否则,如果在浏览器中导航到 /,您的用户将看到一条错误消息。
-
我可以重现您的问题。这一定是个bug。请添加问题github.com/vaadin/spring/issues
-
谢谢,添加了问题:github.com/vaadin/spring/issues/867 目前添加了一个路由别名作为解决方法。弗洛里安
标签: spring vaadin flow vaadin-flow