Vaadin Bakery App 中的登录认证是如何工作的

How does the login authentication work in Vaadin Bakery App

我正在尝试学习 vaadin JAVA 框架。我正在查看 Bakery App 的代码。在 LoginView.java 中调用 setAction('login') 来处理成功的身份验证。我想知道这发生在代码的哪个位置。我只想在现有代码中添加一个新的用户名和密码。怎么做?

Bakery 应用程序使用 Spring 安全性来处理登录逻辑。 Spring 安全配置在 class SecurityConfiguration 中。用户是 UserRepository 中的 loaded/saved,它扩展了 JpaRepository,后者是 Spring Data JPA 框架的一部分。此存储库默认将 Bakery 应用程序内的实体保存在内存中,这在 README.md:

中提到
  1. Optionally you might want to avoid the data generator to be run on each single reload, therefore, make H2 database store entities in file-system instead of in memory by adding the following lines to the src/main/resources/application.properties
spring.datasource.url=jdbc:h2:file:~/bakery-test-data
spring.jpa.hibernate.ddl-auto=update

创建这些用户并保存到内存中的地方在DataGenerator第 77 - 81 行:

    User baker = createBaker(userRepository, passwordEncoder);
    User barista = createBarista(userRepository, passwordEncoder);
    createAdmin(userRepository, passwordEncoder);
    // A set of products without constrains that can be deleted
    createDeletableUsers(userRepository, passwordEncoder);

这是您可以添加其他用户的地方。