Skip to content

Add logging #8589

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
Budlee opened this issue May 24, 2020 · 4 comments
Closed

Add logging #8589

Budlee opened this issue May 24, 2020 · 4 comments
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@Budlee
Copy link
Contributor

Budlee commented May 24, 2020

Expected Behavior

The Jwt Validators that are provided on the oauth jose package have no logging in them when they fail. It makes it hard when debugging to understand when a Jwt Token has failed and for what reason.
I'm not sure if this is on purpose for security reasons to not log the failure

Current Behavior

No loggin in the default JWT Validators

Context

This has slowed down debugging and understanding which validator has failed.
Debug messages when the logging is set to debug would be helpful.

To get an insight into what JWTs are failing have patched the validators and manually setup the JwtDecoder/ReactiveJwtDecoder.

They can not be extended as they are all Final so patching is the only option.

@Budlee Budlee added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels May 24, 2020
@jzheaux
Copy link
Contributor

jzheaux commented May 31, 2020

Thanks for raising this, @Budlee. We certainly want to ensure that there's enough logging available.

Before knowing what the right change is, let's get on the same page about what is missing. In Spring Security, each authentication filter logs failures at the DEBUG level, so you can do:

logging:
  level:
    org.springframework.security: DEBUG

and you'll see failure information, for example when a bearer token fails validation.

On the Servlet side, you'll see an exception like:

...
Caused by: com.nimbusds.jose.proc.BadJWSException: Signed JWT rejected: Invalid signature
	at com.nimbusds.jwt.proc.DefaultJWTProcessor.process(DefaultJWTProcessor.java:405) ~[nimbus-jose-jwt-8.17.1.jar:8.17.1]
	at com.nimbusds.jwt.proc.DefaultJWTProcessor.process(DefaultJWTProcessor.java:330) ~[nimbus-jose-jwt-8.17.1.jar:8.17.1]
	at org.springframework.security.oauth2.jwt.NimbusReactiveJwtDecoder.createClaimsSet(NimbusReactiveJwtDecoder.java:531) ~[spring-security-oauth2-jose-5.4.0-SNAPSHOT.jar:5.4.0-SNAPSHOT]
	... 63 common frames omitted

On the WebFlux side, you'll see a simple message:

Authentication failed: Failed to validate the token

I think things can be improved on the WebFlux side, and perhaps they can be improved on the Servlet side as well.

Can you elaborate on what information that you aren't able to get that you need?

@jzheaux jzheaux added in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 1, 2020
@Budlee
Copy link
Contributor Author

Budlee commented Jun 2, 2020

@jzheaux this is why i did not see it as I am using reactive for pretty much everything currently.

Would you accept a PR that adds more logging to the reactive implementation and are there any constaints?

@jzheaux
Copy link
Contributor

jzheaux commented Jun 2, 2020

Got it, makes sense.

a PR that adds more logging

You've come at the right time. :) Logging is something we're taking a look at generally for the 5.4 release. Some initial work on the reactive side was just merged.

Now, to set expectations, plenty may change in Spring Security's logging story between now and the release. But, I think one place that would probably give you quite a bit more than you have right now would be to log the full exception in AuthenticationWebFilter like is done on the servlet side. Currently, I think it only does "Authentication Failed: " + e.getMessage() or similar.

@Budlee
Copy link
Contributor Author

Budlee commented Jun 8, 2020

@jzheaux i've added some additional debug messages for Jwt and the ReactiveAuth manager. Any suggestions

jzheaux added a commit that referenced this issue Jul 30, 2020
@spring-projects-issues spring-projects-issues added the status: backported An issue that has been backported to maintenance branches label Jul 30, 2020
jzheaux added a commit that referenced this issue Jul 31, 2020
jzheaux added a commit that referenced this issue Jul 31, 2020
jzheaux added a commit that referenced this issue Jul 31, 2020
jzheaux added a commit that referenced this issue Jul 31, 2020
jzheaux added a commit that referenced this issue Jul 31, 2020
jzheaux added a commit that referenced this issue Jul 31, 2020
@jzheaux jzheaux added this to the 5.4.0-RC1 milestone Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants