Skip to content

No Spring-Security logging with Spring-Boot and WebFlux #5758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kensiprell opened this issue Aug 31, 2018 · 11 comments · Fixed by #8504
Closed

No Spring-Security logging with Spring-Boot and WebFlux #5758

kensiprell opened this issue Aug 31, 2018 · 11 comments · Fixed by #8504
Assignees
Labels
type: enhancement A general enhancement

Comments

@kensiprell
Copy link

Summary

I cannot get Spring-Security to log anything in a simple Spring-Boot WebFlux application. I assume I must be doing something wrong because my searches have only turned up this unanswered SO question.

Actual Behavior

No Spring-Boot logging entries appear in terminal window after running ./gradlew bootRun.

Expected Behavior

Detailed logging entries as if using MVC. I followed the same steps to reproduce as shown below, substituting "Web" for "Reactive Web," and it works as expected.

Configuration

macOS 10.13.6
java version "1.8.0_181"

Version

I tried Spring-Booot versions 2.0.4, 2.1.0.M2, and 2.1.0.SNAPSHOT.

Sample

https://github.com/kensiprell/webflux-spring-security-demo

Steps to Reproduce

  1. Go to https://start.spring.io.

  2. Choose Gradle, Kotlin or Java, and a Boot version.

  3. Add 'Security' and 'Reactive Web' to the dependencies and generate the project.

  4. Unarchive demo.zip and cd demo/.

  5. Edit ./src/main/resources/application.properties and add a line that should increase the logging level:
    logging.level.root=DEBUG
    or
    logging.level.org.springframework.security=DEBUG

  6. ./gradlew bootRun

  7. Open http://localhost:8080 in a browser.

@rwinch
Copy link
Member

rwinch commented Aug 31, 2018

You are not doing anything wrong. There really isn't any logging enabled within Spring Security's reactive support. Much of this has to do with the fact that the logging is likely a blocking operation. When I discussed this previously with the Reactor team they had said that there were thoughts around supporting reactive logging, but I just had not followed up on that. It seems like the recommendation is still to configuring logging to be async and that this is a limitation. We can and should add logging to Spring Security.

@rwinch rwinch added this to the 5.1.0 milestone Aug 31, 2018
@rwinch rwinch modified the milestones: 5.1.0, 5.1.1 Sep 17, 2018
@rwinch rwinch modified the milestones: 5.1.1, 5.1.2 Oct 12, 2018
@rwinch rwinch modified the milestones: 5.1.2, 5.1.3 Nov 28, 2018
@rwinch rwinch mentioned this issue Dec 19, 2018
7 tasks
@jzheaux jzheaux modified the milestones: 5.1.3, 5.1.4 Jan 11, 2019
@jgrandja jgrandja modified the milestones: 5.1.4, 5.1.5 Feb 13, 2019
@wtatum
Copy link

wtatum commented Feb 22, 2019

I think I have a good understanding of what makes this so challenging to resolve, but I'd like to quickly voice concern that this isn't being looked into more. There are some use cases that are inherently reactive in nature (a good example is Spring Cloud Gateway) but also strongly benefit from a traceable, auditable security framework.

I also understand the the framework authors can't always "compromise" in the system design, but I think end application often find it acceptable to make small compromises from reactive first principles (i.e. including small potentially blocking calls i.e. logger.debug in their otherwise reactive code. If I need to patch audit logging into my reactive application prior to this ticket being address do you have any advice for me? Is wrapping the existing imperative bean in a Mono.fromCallable or similar enough to "get by".

@KantarBenedictAdamson
Copy link

I came here because I wanted some logging... but the reason I wanted that was that I am trying to debug a failing unit test. So if providing good logging for reactive Spring Security is too difficult for technical reasons, in some circumstances providing better debugging and testing support can be a mitigation.

@jgrandja jgrandja modified the milestones: 5.1.5, 5.1.6 Apr 2, 2019
@dillius
Copy link

dillius commented Apr 7, 2019

Are there any alternative recommendations for debugging security issues until the Reactor team has time to give this some thought?

I'm trying to debug CSRF issues and it is basically guesswork.

@ZhuBicen
Copy link

Any progress?

@rwinch rwinch modified the milestones: 5.1.7, 5.1.8 Nov 4, 2019
@fee1good
Copy link

Guys, really need to have logging security support :)

@jgrandja jgrandja modified the milestones: 5.1.8, 5.1.9 Feb 5, 2020
@eleftherias eleftherias modified the milestones: 5.1.9, 5.1.10 Apr 1, 2020
@samhaque
Copy link

Is there any work around for the time being? I have a spring cloud gateway project being deployed to PCF and require logging for a ReactiveAuthenticationManager implementation.

@rwinch
Copy link
Member

rwinch commented Apr 29, 2020

Any volunteeers for a/some Pull Requests?

@rwinch rwinch added status: ideal-for-contribution An issue that we actively are looking for someone to help us with type: enhancement A general enhancement labels Apr 29, 2020
@mouellet
Copy link
Contributor

mouellet commented May 1, 2020

Hey @rwinch, I've been looking into this and I think if we add some doOnNext here and there (i.e. Filters, Matchers, EntryPoint, etc.), we'll have about the same output as we have on the servlet side.

As for the FilterChainProxy logging (i.e. / at position x of y in additional filter chain; firing Filter: '***Filter'), should this be added in spring-web's DefaultWebFilterChain instead of re-implementing it just to add logs? Or is it specific to spring security?

I'll start working on this and have a PR ready soon!

@rwinch
Copy link
Member

rwinch commented May 1, 2020

should this be added in spring-web's DefaultWebFilterChain instead of re-implementing it just to add logs? Or is it specific to spring security?

We should try to update Spring Framework rather than re-implement things. I'd create a ticket on their side and coordinate with them.

I'll start working on this and have a PR ready soon!

Thanks @mouellet! The issue is yours.

@eleftherias eleftherias modified the milestones: 5.1.10, 5.1.11 May 6, 2020
mouellet added a commit to mouellet/spring-security that referenced this issue May 8, 2020
Goal is to provide insight to devs on:
- Authentication & Authorization success/failures
- WebSession & SecurityContext
- Request matchers, cache & authn/authz flow

Fixes spring-projectsgh-5758
rwinch pushed a commit that referenced this issue May 12, 2020
Goal is to provide insight to devs on:
- Authentication & Authorization success/failures
- WebSession & SecurityContext
- Request matchers, cache & authn/authz flow

Fixes gh-5758
@rwinch rwinch removed this from the 5.1.11 milestone May 12, 2020
@rwinch rwinch removed the status: ideal-for-contribution An issue that we actively are looking for someone to help us with label May 12, 2020
@rwinch
Copy link
Member

rwinch commented May 12, 2020

I closed this in favor of gh-8504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.