Merge branch '7.0.x'
This commit is contained in:
+3
-4
@@ -380,11 +380,10 @@ public class SpringOpaqueTokenIntrospector implements OpaqueTokenIntrospector {
|
|||||||
* @since 6.5
|
* @since 6.5
|
||||||
*/
|
*/
|
||||||
public SpringOpaqueTokenIntrospector build() {
|
public SpringOpaqueTokenIntrospector build() {
|
||||||
|
Assert.notNull(this.clientId, "clientId cannot be null");
|
||||||
|
Assert.notNull(this.clientSecret, "clientSecret cannot be null");
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
if (this.clientId != null && this.clientSecret != null) {
|
restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor(this.clientId, this.clientSecret));
|
||||||
restTemplate.getInterceptors()
|
|
||||||
.add(new BasicAuthenticationInterceptor(this.clientId, this.clientSecret));
|
|
||||||
}
|
|
||||||
SpringOpaqueTokenIntrospector introspector = new SpringOpaqueTokenIntrospector(this.introspectionUri,
|
SpringOpaqueTokenIntrospector introspector = new SpringOpaqueTokenIntrospector(this.introspectionUri,
|
||||||
restTemplate);
|
restTemplate);
|
||||||
this.postProcessors.forEach((postProcessor) -> postProcessor.accept(introspector));
|
this.postProcessors.forEach((postProcessor) -> postProcessor.accept(introspector));
|
||||||
|
|||||||
+5
-5
@@ -334,13 +334,13 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
|
|||||||
* @since 6.5
|
* @since 6.5
|
||||||
*/
|
*/
|
||||||
public SpringReactiveOpaqueTokenIntrospector build() {
|
public SpringReactiveOpaqueTokenIntrospector build() {
|
||||||
WebClient.Builder builder = WebClient.builder();
|
Assert.notNull(this.clientId, "clientId cannot be null");
|
||||||
if (this.clientId != null && this.clientSecret != null) {
|
Assert.notNull(this.clientSecret, "clientSecret cannot be null");
|
||||||
String clientId = this.clientId;
|
String clientId = this.clientId;
|
||||||
String clientSecret = this.clientSecret;
|
String clientSecret = this.clientSecret;
|
||||||
builder.defaultHeaders((h) -> h.setBasicAuth(clientId, clientSecret));
|
WebClient webClient = WebClient.builder()
|
||||||
}
|
.defaultHeaders((h) -> h.setBasicAuth(clientId, clientSecret))
|
||||||
WebClient webClient = builder.build();
|
.build();
|
||||||
SpringReactiveOpaqueTokenIntrospector introspector = new SpringReactiveOpaqueTokenIntrospector(
|
SpringReactiveOpaqueTokenIntrospector introspector = new SpringReactiveOpaqueTokenIntrospector(
|
||||||
this.introspectionUri, webClient);
|
this.introspectionUri, webClient);
|
||||||
this.postProcessors.forEach((postProcessor) -> postProcessor.accept(introspector));
|
this.postProcessors.forEach((postProcessor) -> postProcessor.accept(introspector));
|
||||||
|
|||||||
+7
@@ -402,6 +402,13 @@ public class SpringOpaqueTokenIntrospectorTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gh-19201
|
||||||
|
@Test
|
||||||
|
public void builderWhenMissingClientCredentialsThenThrowsException() {
|
||||||
|
assertThatExceptionOfType(IllegalArgumentException.class)
|
||||||
|
.isThrownBy(() -> SpringOpaqueTokenIntrospector.withIntrospectionUri(INTROSPECTION_URL).build());
|
||||||
|
}
|
||||||
|
|
||||||
private static ResponseEntity<Map<String, Object>> response(String content) {
|
private static ResponseEntity<Map<String, Object>> response(String content) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|||||||
+7
@@ -328,6 +328,13 @@ public class SpringReactiveOpaqueTokenIntrospectorTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gh-19201
|
||||||
|
@Test
|
||||||
|
public void builderWhenMissingClientCredentialsThenThrowsException() {
|
||||||
|
assertThatExceptionOfType(IllegalArgumentException.class)
|
||||||
|
.isThrownBy(() -> SpringReactiveOpaqueTokenIntrospector.withIntrospectionUri(INTROSPECTION_URL).build());
|
||||||
|
}
|
||||||
|
|
||||||
private WebClient mockResponse(String response) {
|
private WebClient mockResponse(String response) {
|
||||||
return mockResponse(toMap(response));
|
return mockResponse(toMap(response));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user