Skip to content

Commit 578a559

Browse files
committed
allow other body params (should've read the whole rfc 6750 doc)
1 parent 6803ac4 commit 578a559

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/web/server/authentication/ServerBearerTokenAuthenticationConverter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ private Mono<String> resolveAccessTokenFromBody(ServerWebExchange exchange) {
180180
if (formData.isEmpty()) {
181181
return null;
182182
}
183-
if (formData.size() > 1) {
184-
var error = invalidRequest("The HTTP request entity-body is not single-part");
185-
throw new OAuth2AuthenticationException(error);
186-
}
187183
final var tokens = formData.get(ACCESS_TOKEN_NAME);
188184
if (tokens == null) {
189185
return null;

oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/web/server/authentication/ServerBearerTokenAuthenticationConverterTests.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,20 +256,12 @@ void resolveWhenBodyParameterHasMultipleAccessTokensThenOAuth2AuthenticationExce
256256
}
257257

258258
@Test
259-
void resolveWhenBodyParameterIsNotSinglePartThenOAuth2AuthenticationException() {
259+
void resolveBodyContainsOtherParameterAsWellThenTokenIsResolved() {
260260
this.converter.setAllowFormEncodedBodyParameter(true);
261261
var request = post("/").contentType(APPLICATION_FORM_URLENCODED)
262262
.body("access_token=" + TEST_TOKEN + "&other_param=value");
263263

264-
assertThatExceptionOfType(OAuth2AuthenticationException.class)
265-
.isThrownBy(() -> convertToToken(request))
266-
.satisfies(ex -> {
267-
BearerTokenError error = (BearerTokenError) ex.getError();
268-
assertThat(error.getDescription()).isEqualTo("The HTTP request entity-body is not single-part");
269-
assertThat(error.getErrorCode()).isEqualTo(BearerTokenErrorCodes.INVALID_REQUEST);
270-
assertThat(error.getUri()).isEqualTo("https://tools.ietf.org/html/rfc6750#section-3.1");
271-
assertThat(error.getHttpStatus()).isEqualTo(HttpStatus.BAD_REQUEST);
272-
});
264+
assertThat(convertToToken(request).getToken()).isEqualTo(TEST_TOKEN);
273265
}
274266

275267
@Test

0 commit comments

Comments
 (0)