【问题标题】:Spring Security 5 logging for reactive applications响应式应用程序的 Spring Security 5 日志记录
【发布时间】:2018-09-27 08:50:35
【问题描述】:

目前将 Spring Boot 2.0.1Spring Security 5.0.4 一起用于 reactive 应用程序。

问题是我根本没有得到任何 Spring Security 日志。

额外细节:

  • 我在 application.properties 中有 “logging.level.org.springframework.security=DEBUG”。记录器执行器证明了这一点。

  • Spring Security 已正确启用,因为未经身份验证的访问正确返回 401 状态。

  • 对于命令式 Spring Boot 2.0.1 应用程序,我正确获取了 Spring Security 日志。

我错过了什么吗?如何在响应式应用程序中启用 Spring Security 5 日志(最好使用属性而不是代码)?

感谢您的宝贵时间。

更新 1:在 https://github.com/fbeaufume/webflux-security-sample 上传了一个 MWE

更新 2:我的应用程序的 Spring Security 配置基于 http://www.baeldung.com/spring-security-5-reactive(可能已被弃用,因为它使用 Spring Boot 2.0.0.M6)但还不能工作。

更新 3:当使用来自 https://github.com/spring-projects/spring-boot/tree/v2.0.1.RELEASE/spring-boot-samples/spring-boot-sample-secure-webflux 的代码时,Spring Security 工作但仍然没有日志

【问题讨论】:

标签: java spring spring-security reactive-programming


【解决方案1】:

现在可以从 5.4.0-M2 版本开始为 webflux 反应式应用程序提供 Spring 安全日志记录(正如 @bzhu 在评论 How do I enable logging for Spring Security? 中提到的那样)

直到它进入 GA 版本,这里是如何在 gradle 中获得这个里程碑版本

repositories {
    mavenCentral()
    if (!version.endsWith('RELEASE')) {
        maven { url "https://repo.spring.io/milestone" }
    }
}

// Force earlier milestone release to get securing logging preview
// https://docs.spring.io/spring-security/site/docs/current/reference/html5/#getting-gradle-boot
ext['spring-security.version']='5.4.0-M2'
dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-28
    • 1970-01-01
    • 1970-01-01
    • 2014-10-01
    • 1970-01-01
    • 2018-09-09
    • 1970-01-01
    • 2011-03-27
    相关资源
    最近更新 更多