Spring Boot 2.0:登录尝试失败,默认安全性为

时间:2018-04-13 19:46:12

标签: java spring spring-boot spring-security

我目前正在努力设置一个具有默认安全性的基本Spring Boot 2应用程序(根据Spring Boot 2.0 Migration Guide)。

我的问题是,虽然我没有创建自定义WebSecurityConfigurationAdapter我无法使用默认表单登录(使用生成的密码)登录,但登录页面只是刷新,没有显示凭据的指示正确或不正确。这是登录尝试后的页面:

Page after login attempt

gradle.build文件:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
    }
}

apply plugin: "java"
apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"

bootJar {
    baseName = "sample-service"
    version =  "0.0.1"
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web"
    testCompile "org.springframework.boot:spring-boot-starter-test"

    // DevTools
    compile "org.springframework.boot:spring-boot-devtools"

    // Security
    compile "org.springframework.boot:spring-boot-starter-security"
}

未解决此问题的操作:

  1. 配置模仿默认安全性的自定义WebSecurityConfigurerAdapter
  2. 使用@EnableWebSecurity
  3. 明确定义PasswordEncoder
  4. 我是否会错过有关Spring Boot 2.0中引入的默认安全性的一些信息?

    更新1:

    /error页面受默认安全保护,因此显示了新的/login页面(重定向到错误页面时)。 使用调试日志级别(由mohax建议)跳过日志我找到了条目

    2018-04-14 17:49:51.680 DEBUG 236 --- [nio-8080-exec-5] o.a.c.c.C.[Tomcat].[localhost]           : Processing ErrorPage[errorCode=0, location=/error]
    

    收到登录发帖请求时。这很奇怪,因为登录时没有显示错误。使用配置程序WebSecurity忽略错误页面会导致登录尝试后显示403 Forbidden错误。

0 个答案:

没有答案
相关问题