出现一个未知的登录页面

时间:2018-12-10 12:23:14

标签: java spring-boot

我正在尝试了解这个春季启动项目:hbs-spring-boot-jpa-mysql-thymeleaf-security
在HbsController中,代码为
enter image description here
如我所知,当我输入localhost:8080/hbs时,我应该看到索引页面了吗?但我只能看到它
enter image description here
,然后我查看了项目
enter image description here
我找不到登录页面?它在哪里?请帮助我。

2 个答案:

答案 0 :(得分:2)

我认为这是因为pom文件/项目https://spring.io/guides/gs/securing-web/

中已实现/包含了spring boot安全性。

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

答案 1 :(得分: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的配置类,它将起作用