-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix to ensure endpoints distinguish between form and query parameters #1468
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| import org.springframework.context.annotation.Import; | ||
| import org.springframework.http.HttpHeaders; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.converter.HttpMessageConverter; | ||
| import org.springframework.jdbc.core.JdbcOperations; | ||
| import org.springframework.jdbc.core.JdbcTemplate; | ||
|
|
@@ -355,7 +356,8 @@ private OAuth2AccessTokenResponse assertTokenRequestReturnsAccessTokenResponse(R | |
| OAuth2Authorization authorization, String tokenEndpointUri) throws Exception { | ||
| MvcResult mvcResult = this.mvc.perform(post(tokenEndpointUri) | ||
| .params(getTokenRequestParameters(registeredClient, authorization)) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient))) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient)) | ||
| .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) | ||
|
||
| .andExpect(status().isOk()) | ||
| .andExpect(header().string(HttpHeaders.CACHE_CONTROL, containsString("no-store"))) | ||
| .andExpect(header().string(HttpHeaders.PRAGMA, containsString("no-cache"))) | ||
|
|
@@ -406,7 +408,8 @@ public void requestWhenPublicClientWithPkceThenReturnAccessTokenResponse() throw | |
| this.mvc.perform(post(DEFAULT_TOKEN_ENDPOINT_URI) | ||
| .params(getTokenRequestParameters(registeredClient, authorizationCodeAuthorization)) | ||
| .param(OAuth2ParameterNames.CLIENT_ID, registeredClient.getClientId()) | ||
| .param(PkceParameterNames.CODE_VERIFIER, S256_CODE_VERIFIER)) | ||
| .param(PkceParameterNames.CODE_VERIFIER, S256_CODE_VERIFIER) | ||
| .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) | ||
| .andExpect(header().string(HttpHeaders.CACHE_CONTROL, containsString("no-store"))) | ||
| .andExpect(header().string(HttpHeaders.PRAGMA, containsString("no-cache"))) | ||
| .andExpect(status().isOk()) | ||
|
|
@@ -498,7 +501,8 @@ public void requestWhenCustomTokenGeneratorThenUsed() throws Exception { | |
|
|
||
| this.mvc.perform(post(DEFAULT_TOKEN_ENDPOINT_URI) | ||
| .params(getTokenRequestParameters(registeredClient, authorization)) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient))) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient)) | ||
| .contentType(MediaType.APPLICATION_FORM_URLENCODED)) | ||
| .andExpect(status().isOk()); | ||
|
|
||
| verify(this.tokenGenerator, times(2)).generate(any()); | ||
|
|
@@ -575,7 +579,8 @@ public void requestWhenConsentRequestThenReturnAccessTokenResponse() throws Exce | |
|
|
||
| this.mvc.perform(post(DEFAULT_TOKEN_ENDPOINT_URI) | ||
| .params(getTokenRequestParameters(registeredClient, authorizationCodeAuthorization)) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient))) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient)) | ||
| .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) | ||
| .andExpect(status().isOk()) | ||
| .andExpect(header().string(HttpHeaders.CACHE_CONTROL, containsString("no-store"))) | ||
| .andExpect(header().string(HttpHeaders.PRAGMA, containsString("no-cache"))) | ||
|
|
@@ -662,7 +667,8 @@ public void requestWhenCustomConsentCustomizerConfiguredThenUsed() throws Except | |
|
|
||
| mvcResult = this.mvc.perform(post(DEFAULT_TOKEN_ENDPOINT_URI) | ||
| .params(getTokenRequestParameters(registeredClient, authorizationCodeAuthorization)) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient))) | ||
| .header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(registeredClient)) | ||
| .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) | ||
| .andExpect(status().isOk()) | ||
| .andExpect(header().string(HttpHeaders.CACHE_CONTROL, containsString("no-store"))) | ||
| .andExpect(header().string(HttpHeaders.PRAGMA, containsString("no-cache"))) | ||
|
|
@@ -757,7 +763,8 @@ public void requestWhenClientObtainsAccessTokenThenClientAuthenticationNotPersis | |
| mvcResult = this.mvc.perform(post(DEFAULT_TOKEN_ENDPOINT_URI) | ||
| .params(getTokenRequestParameters(registeredClient, authorizationCodeAuthorization)) | ||
| .param(OAuth2ParameterNames.CLIENT_ID, registeredClient.getClientId()) | ||
| .param(PkceParameterNames.CODE_VERIFIER, S256_CODE_VERIFIER)) | ||
| .param(PkceParameterNames.CODE_VERIFIER, S256_CODE_VERIFIER) | ||
| .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) | ||
| .andExpect(header().string(HttpHeaders.CACHE_CONTROL, containsString("no-store"))) | ||
| .andExpect(header().string(HttpHeaders.PRAGMA, containsString("no-cache"))) | ||
| .andExpect(status().isOk()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can be simplified. Given the existing
getParameters()method, the only change required to make it function asgetFormParameters()is:And for
getQueryParameters(), applyingif (request.getQueryString().contains(key) ...would work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. That's a simple way to implement that.