spring-boot - 春季启动的Vaadin登录问题
问题描述
我对 Vaadin (v. 14.6.1) 和 Spring boot (v. 2.4.5) 有一个奇怪的问题。我已按照https://vaadin.com/learn/tutorials/securing-your-app-with-spring-security/setting-up-spring-security中的说明来实现登录视图和安全设置。
当我加载应用程序并转到 localhost/8080 登录时,我输入了正确的凭据,但登录失败并显示消息
WARN 8184 --- [io-8080-exec-10] cvfscUidlRequestHandler:从 0:0:0:0:0:0:0:1 收到的安全密钥无效
当我尝试使用相同的凭据再次登录时,登录成功。如果我注销并尝试再次登录,它工作正常。
我可以通过重新启动服务器并尝试再次登录来重现此问题。我在开发模式和生产模式下测试了这个问题,并得到了相同的行为。
解决方案
我发现您的代码有两个问题:
- 安全实用程序
该ServletHelper
课程已被弃用,我认为这会导致问题。我将其替换为HandlerHelper
:
public class SecurityUtils {
/**
* Tests if the request is an internal framework request. The test consists of
* checking if the request parameter is present and if its value is consistent
* with any of the request types know.
*
* @param request
* {@link HttpServletRequest}
* @return true if is an internal framework request. False otherwise.
*/
static boolean isFrameworkInternalRequest(HttpServletRequest request) {
final String parameterValue = request.getParameter(ApplicationConstants.REQUEST_TYPE_PARAMETER);
return parameterValue != null && Stream.of(HandlerHelper.RequestType.values())
.anyMatch(r -> r.getIdentifier().equals(parameterValue));
}
- 缺少 Vaadin 插件(如果您使用 Maven 运行它,则必须运行准备前端)
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-frontend</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
推荐阅读
- javascript - 通过 Detox 测试进行 API 调用
- kendo-grid - KENDO MVC GRID / ClientTemplate 中的算术运算
- ios - 基于 GPS 坐标 iOS 在 AR 中放置对象
- azure - 域加入 HdInsight 集群 hdfs 用户权限
- sql-server - 如何根据查找另外两组列来计算列中的总和?
- python - 当 TCP 服务器读取非阻塞套接字时,TCP 客户端是否能够暂停服务器
- unity3d - Nuxt (vue) 和 Unity 的 Unityloader 内存泄漏
- android - 什么是 {"456"} for transform: (String) -> String in Kotlin 的完整代码?
- java - 如何避免stackoverflow异常
- ios - 动画根视图控制器转换