首页 文章

显示一个未知的登录页面

提问于
浏览
1

我想了解这个 Spring 季启动项目:hbs-spring-boot-jpa-mysql-thymeleaf-security
在HbsController中代码是

据我所知,当我输入 localhost:8080/hbs 时,我应该看到索引页面正确吗?但我只能看到这个

我调查了这个项目

我找不到登录页面?它在哪里?请帮我 .

2 回答

  • 2

    我认为这是因为pom文件/项目中实现/包含了spring boot安全性:https://spring.io/guides/gs/securing-web/

    您可以在“security”文件夹中的“SpringSecurity.java”类中看到spring安全性配置 . 您可以在那里修改它或查找凭据是什么 .

  • 2

    在SecurityConfig中,您可能需要具有授权的/ hbs映射 .

    在这个例子中https://www.baeldung.com/spring-security-login

    @Override
    protected void configure(final HttpSecurity http) throws Exception {
        http
          .csrf().disable()
          .authorizeRequests()
          .antMatchers("/admin/**").hasRole("ADMIN")
          .antMatchers("/anonymous*").anonymous()
          .antMatchers("/login*").permitAll()
          .anyRequest().authenticated()
          .and()
          .formLogin()
          .loginPage("/login.html")
          .loginProcessingUrl("/perform_login")
          .defaultSuccessUrl("/homepage.html", true)
          //.failureUrl("/login.html?error=true")
          .failureHandler(authenticationFailureHandler())
          .and()
          .logout()
          .logoutUrl("/perform_logout")
          .deleteCookies("JSESSIONID")
          .logoutSuccessHandler(logoutSuccessHandler());
    }
    

    “.antMatchers(”/ admin / **“) . hasRole(”ADMIN“)”仅强制访问“ADMIN”用户并将其重定向到/ login

    尝试修改实现WebSecurityConfigurerAdapter的配置类,它将起作用

相关问题