Skip to content

Fix token endpoint filter for authorization code flow #120 #121

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

Conversation

vincent-hsin
Copy link

@vincent-hsin vincent-hsin commented Sep 24, 2020

Whether request with client_id parameter or not , client Principal should be get.

@pivotal-issuemaster
Copy link

@vincent-hsin 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-issuemaster
Copy link

@vincent-hsin Thank you for signing the Contributor License Agreement!

Copy link
Collaborator

@jgrandja jgrandja left a comment

Choose a reason for hiding this comment

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

@vincent-hsin Please see comment.

}
clientPrincipal = SecurityContextHolder.getContext().getAuthentication();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Moving this line of code does not change any behaviour from the original. As an FYI, if you feel this is a bug, a test must be provided to demonstrate the bug.

@jgrandja jgrandja self-assigned this Sep 24, 2020
@vincent-hsin vincent-hsin changed the title fix access token request bug Fix token endpoint filter for authorization code flow #120 Sep 25, 2020
Copy link
Author

@vincent-hsin vincent-hsin left a comment

Choose a reason for hiding this comment

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

A unit test for the bug

@@ -257,6 +257,57 @@ public void doFilterWhenAuthorizationCodeTokenRequestValidThenAccessTokenRespons
assertThat(accessTokenResult.getScopes()).isEqualTo(accessToken.getScopes());
}

@Test
Copy link
Author

Choose a reason for hiding this comment

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

@jgrandja this unit test for #120

MockHttpServletRequest request = new MockHttpServletRequest("POST", requestUri);
request.setServletPath(requestUri);

request.addParameter(OAuth2ParameterNames.GRANT_TYPE, AuthorizationGrantType.AUTHORIZATION_CODE.getValue());
Copy link
Collaborator

Choose a reason for hiding this comment

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

@vincent-hsin This request is invalid.

As per spec, in Section 4.1.3. Access Token Request:

If the client type is confidential or the client was issued client
credentials (or assigned other authentication requirements), the
client MUST authenticate with the authorization server as described
in Section 3.2.1.

Only confidential clients are supported at the moment, so the client MUST authenticate at the token endpoint.

The change in this PR would allow a malicious user to obtain a token.

FYI, public client authentication support is coming in #45.

I'm going to close this PR and associated issue based on the above explanation.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I got it. I will contribute for #45.

Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI, there is a PR for #45. See #93

@jgrandja jgrandja closed this Sep 25, 2020
@jgrandja jgrandja added the status: declined A suggestion or change that we don't feel we should currently apply label Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants