Skip to content

Log a warning when AuthorizationGrantType does not exactly match a pre-defined constant #12087

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

Conversation

msosa
Copy link
Contributor

@msosa msosa commented Oct 26, 2022

This adds the warning when AuthorizationGrantType does not exactly match what is expected as discussed on gh-11905

@pivotal-cla
Copy link

@msosa Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@msosa Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 26, 2022
Copy link
Contributor

@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.

Hi @msosa, thanks for the PR! I've provided some feedback inline below.

@sjohnr sjohnr self-assigned this Oct 27, 2022
@msosa msosa requested a review from sjohnr October 31, 2022 05:48
@sjohnr sjohnr added status: duplicate A duplicate of another issue type: enhancement A general enhancement 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 Nov 9, 2022
Copy link
Contributor

@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.

Hi @msosa! Apologies for the delay reviewing this PR again. We've been heads down working on the 6.0 release.

There are a couple of additional items to address below. Also, please update the copyright year in the header. Please ensure the branch is rebased on 5.8.x and commits are squashed. Lastly, please add Closes gh-11905 on a separate line in the commit message.

Would you like to address yourself? Or would you like me to address them in a polish commit to get this in time for 5.8.0?

@@ -46,6 +50,12 @@
public final class ClientRegistration implements Serializable {

private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
private static final Log logger = LogFactory.getLog(ClientRegistration.class);

private static final List<AuthorizationGrantType> authorizationGrantTypes =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be adjusted to be a constant name (all caps, e.g. AUTHORIZATION_GRANT_TYPES)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would also suggest moving this down to the Builder.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Clarification: I would suggest moving both lines down into the Builder and the logger would reference ClientRegistration.Builder.class instead.)

for (AuthorizationGrantType authorizationGrantType : authorizationGrantTypes) {
if (authorizationGrantType.getValue().equalsIgnoreCase(this.authorizationGrantType.getValue()) &&
!authorizationGrantType.equals(this.authorizationGrantType)) {
logger.warn(LogMessage.format("AuthorizationGrantType: %s does not match the pre-defined" +
Copy link
Contributor

Choose a reason for hiding this comment

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

You can run ./gradlew format to format these changes per the contributing guidelines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, also made me realize I was missing a space.

@msosa msosa force-pushed the client-registration-warnings branch from 117228c to 1b96295 Compare November 17, 2022 01:32
@msosa msosa force-pushed the client-registration-warnings branch from 1b96295 to 053d944 Compare November 17, 2022 01:34
@msosa
Copy link
Contributor Author

msosa commented Nov 17, 2022

@sjohnr I have updated the review, if there is anything I missed or something else you noticed, please feel free to do a polish commit to get this into 5.8.0

@msosa msosa requested a review from sjohnr November 17, 2022 01:36
sjohnr pushed a commit that referenced this pull request Nov 17, 2022
@sjohnr
Copy link
Contributor

sjohnr commented Nov 17, 2022

Merged via 52888d6. Polish commit 4e88623 added to remove IMPLICIT in 6.0.

@sjohnr sjohnr closed this Nov 17, 2022
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.

4 participants