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

Allow custom OAuth2ErrorHttpMessageConverter with OAuth2ErrorResponse… #10432

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

khamlaoui
Copy link

Expected Behavior

When we get errors from IDP (in our case its Okta), we should get a correctly formed OAuth2Error with the error code and description.

Current Behavior

The root cause error is lost, because the error conversion is not compliant with OKTA error response.
Okta error example:
{ "errorCode": "invalid_client", "errorSummary": "Invalid value for 'client_id' parameter.", "errorLink": "invalid_client", "errorId": "oaeUy44O3E3Q6mR4ZIcy50gKg", "errorCauses": [] }
The OAuth2ErrorConverter try to map mandatory parameter with name error however with Okta this attribute is named with errorCode

At the end, we lost the Okta error, and we get IllegalArgumentException raised by the constructor of OAuth2Error

A quick fix, could be allowing setter for OAuth2ErrorHttpMessageConverter in OAuth2ErrorResponseErrorHandler or add a constructor with OAuth2ErrorHttpMessageConverter .

Closes gh-10425

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 21, 2021
@sjohnr sjohnr self-assigned this Oct 21, 2021
@sjohnr sjohnr added in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 21, 2021
Copy link
Member

@sjohnr sjohnr left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @khamlaoui. This is a great start! I have added some feedback inline, see below.

Copy link
Member

@sjohnr sjohnr left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, @khamlaoui! Just a few more updates noted below. When finished, please squash your changes into a single commit.

@khamlaoui
Copy link
Author

@sjohnr changes are pushed and commits squashed

@khamlaoui
Copy link
Author

@sjohnr sorry i was missing to rethrow the checked. IOException.

@khamlaoui
Copy link
Author

@sjohnr i fixed the issue with test checkstyle

@rwinch
Copy link
Member

rwinch commented Oct 22, 2021

While probably not the most popular opinion, I think we should wait until 5.7. The change is minor, but we really need to do our best to stick to semantic versioning unless there is an extremely good reason to do otherwise. The workaround for this is that users can copy a single class and add the setter and then delete the copy when 5.7 becomes available in 6 months.

@sjohnr sjohnr added this to the 5.7.x milestone Oct 22, 2021
@khamlaoui
Copy link
Author

@rwinch what is the risk associated with integrating this small change in 5.6?

@khamlaoui
Copy link
Author

@sjohnr do i have to change the since to 5.7 ?

@sjohnr
Copy link
Member

sjohnr commented Oct 23, 2021

@sjohnr do i have to change the since to 5.7 ?

If you could, that would be great. Actually, looks like you have already, thanks!

I think Rob's point is that we should stick to our stated policy on semantic versioning, not so much that there's a specific risk. Thanks for the contribution @khamlaoui! Appreciate the fast turnaround even so.

@khamlaoui
Copy link
Author

@sjohnr thanks for feedbacks !
I will try to contribute if possible to add a feature for private_key_jwt( load public and private keys from keystore)

@sjohnr sjohnr merged commit 498636e into spring-projects:main Nov 16, 2021
@sjohnr sjohnr modified the milestones: 5.7.x, 6.0.0-M1 Nov 16, 2021
@sjohnr sjohnr modified the milestones: 6.0.0-M1, 5.7.0-M1 Dec 1, 2021
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: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom OAuth2ErrorHttpMessageConverter with OAuth2ErrorResponseErrorHandler
6 participants