Skip to content
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

Improve logging #1467

Closed
wants to merge 6 commits into from
Closed

Improve logging #1467

wants to merge 6 commits into from

Conversation

leshalv
Copy link
Contributor

@leshalv leshalv commented Dec 1, 2023

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 1, 2023
if (this.logger.isWarnEnabled()) {
this.logger.warn(LogMessage.format("Invalidated redirect_uri used by registered client '%s'", registeredClient.getId()));
}
OAuth2Error error = new OAuth2Error(OAuth2ErrorCodes.INVALID_GRANT,"The redirect_uri does not match the redirection URI used in the authorization request.",ERROR_URI);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leshalv We do not want to reveal too much information to the caller as it can provide hints to perform other operations in order to gain access. It is intentional to return only a general error code.

At some point, we may look at addressing this in gh-1240.

I'm going to close this PR for reasons explained above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When docking integration, it is easy to have some problems, when troubleshooting problems, it is difficult to know the specific problem, here is my reference to okta back to do, which should not affect major security

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could consider the PR, including its log input, masking this detail in the exception handler, which can be customized by a custom exception handler if the developer wants to return it.
@jgrandja

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At present, I look at the implementation, only the server exception is returned details, in fact, we can do not return details of the INVALID_GRANT exception in the exception handler, the decision is left to the user-defined processor.
@jgrandja

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently developing IAM systems based on springsecurity, and there are a lot of issues around exceptions, because there is no log print there, it is difficult to know what is going on. I have also looked at Okta, Auth0 and other SSO platforms, and I find that everyone has different wrong responses. I can also override this implementation, but considering the connection with the upstream, including subsequent upgrades, I think this piece should be synchronized to the upstream, perhaps we can optimize this piece through other ways, such as in the exception processor mask, the user through the custom processor open.
@jgrandja

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leshalv I would be open to enhancing the trace logging if that works for you?

Copy link
Contributor Author

@leshalv leshalv Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leshalv I would be open to enhancing the trace logging if that works for you?

Enhancing trace was a good decision.
Can you consider masking described scenarios in exception handlers? Because we've done the same thing on other processors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leshalv I would be open to enhancing the trace logging if that works for you?

I think we can reference OAuth2ClientAuthenticationFilter processing implementation, does not return to the default, the user can customize the processor to open, believe me, it's really elegant.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leshalv I'm reopening this PR so feel free to update it with trace logging only.

Can you consider masking described scenarios in exception handlers?

OAuth2ClientAuthenticationFilter is the only Filter that does this at the moment and I'm not sure I want to follow this pattern for all Filter's. I'd rather give it some further thought and come up with a more holistic solution that we will address in gh-1240, when we schedule the time to work on it.

@jgrandja jgrandja closed this Dec 5, 2023
@jgrandja jgrandja added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 5, 2023
@jgrandja jgrandja self-assigned this Dec 5, 2023
@jgrandja jgrandja reopened this Dec 6, 2023
@jgrandja jgrandja changed the title Improvement OAuth2AuthorizationCodeAuthenticationProvider Improve logging in OAuth2AuthorizationCodeAuthenticationProvider Dec 6, 2023
@jgrandja jgrandja added type: enhancement A general enhancement and removed status: declined A suggestion or change that we don't feel we should currently apply labels Dec 6, 2023
@leshalv leshalv changed the title Improve logging in OAuth2AuthorizationCodeAuthenticationProvider Improve logging Dec 15, 2023
@leshalv
Copy link
Contributor Author

leshalv commented Dec 15, 2023

@jgrandja I made logging enhancements in some key places.

@jgrandja
Copy link
Collaborator

@leshalv Apologies I didn't have time to review the changes.

I'm off for the holidays and back Jan 8. I will review it the week I'm back.

Enjoy the holidays!

@jgrandja jgrandja added this to the 1.3.0-M1 milestone Jan 15, 2024
@jgrandja jgrandja closed this in 6638181 Jan 15, 2024
jgrandja added a commit that referenced this pull request Jan 15, 2024
@jgrandja
Copy link
Collaborator

Thanks for the updates @leshalv. This is now merged. FYI, I added a polish commit with some minor updates.

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
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants