parent
7cc6509200
commit
d38dabac02
|
@ -110,7 +110,7 @@ public final class DefaultBearerTokenResolver implements BearerTokenResolver {
|
||||||
throw new OAuth2AuthenticationException(error);
|
throw new OAuth2AuthenticationException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return matcher.group("token");
|
return authorization.substring(7);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatCode;
|
||||||
*/
|
*/
|
||||||
public class DefaultBearerTokenResolverTests {
|
public class DefaultBearerTokenResolverTests {
|
||||||
private static final String CUSTOM_HEADER = "custom-header";
|
private static final String CUSTOM_HEADER = "custom-header";
|
||||||
private static final String TEST_TOKEN = "test-token";
|
private static final String TEST_TOKEN = "ab5FG/ywfXPwiPc6ErRQM643QqY";
|
||||||
|
|
||||||
private DefaultBearerTokenResolver resolver;
|
private DefaultBearerTokenResolver resolver;
|
||||||
|
|
||||||
|
@ -51,6 +51,24 @@ public class DefaultBearerTokenResolverTests {
|
||||||
assertThat(this.resolver.resolve(request)).isEqualTo(TEST_TOKEN);
|
assertThat(this.resolver.resolve(request)).isEqualTo(TEST_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void resolveWhenValidHeaderIsPresentWithSingleBytePaddingIndicatorThenTokenIsResolved() {
|
||||||
|
String token = TEST_TOKEN + "=";
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
request.addHeader("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
assertThat(this.resolver.resolve(request)).isEqualTo(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void resolveWhenValidHeaderIsPresentWithTwoBytesPaddingIndicatorThenTokenIsResolved() {
|
||||||
|
String token = TEST_TOKEN + "==";
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
request.addHeader("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
|
assertThat(this.resolver.resolve(request)).isEqualTo(token);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resolveWhenCustomDefinedHeaderIsValidAndPresentThenTokenIsResolved() {
|
public void resolveWhenCustomDefinedHeaderIsValidAndPresentThenTokenIsResolved() {
|
||||||
this.resolver.setBearerTokenHeaderName(CUSTOM_HEADER);
|
this.resolver.setBearerTokenHeaderName(CUSTOM_HEADER);
|
||||||
|
|
Loading…
Reference in New Issue