Skip to content

Commit 8c8487f

Browse files
committed
Merge branch 'resubscribe-on-token-expiration' into 3.x
Signed-off-by: Ben Hale <[email protected]>
2 parents 9cc5ea9 + 5b8516b commit 8c8487f

File tree

7 files changed

+39
-19
lines changed

7 files changed

+39
-19
lines changed

.idea/runConfigurations/integration_test.xml

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
2222
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
2323
import io.netty.buffer.PooledByteBufAllocator;
24+
import io.netty.handler.logging.LogLevel;
2425
import io.netty.handler.ssl.SslContextBuilder;
2526
import org.cloudfoundry.Nullable;
2627
import org.cloudfoundry.reactor.util.ByteBufAllocatorMetricProviderWrapper;
@@ -268,6 +269,7 @@ private TcpClient configureTcpClient(TcpClient tcpClient) {
268269
.option(SO_SNDBUF, SEND_RECEIVE_BUFFER_SIZE)
269270
.option(SO_RCVBUF, SEND_RECEIVE_BUFFER_SIZE);
270271
tcpClient = configureKeepAlive(tcpClient);
272+
tcpClient = tcpClient.wiretap("cloudfoundry-client.wire", LogLevel.TRACE);
271273

272274
return configureConnectTimeout(tcpClient);
273275
}

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/uaa/AbstractUaaOperations.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ protected final Mono<HttpClientResponse> get(Object requestPayload, Function<Uri
7070
.get());
7171
}
7272

73+
protected final Mono<HttpClientResponse> get(Object requestPayload, Function<UriComponentsBuilder, UriComponentsBuilder> uriTransformer, Consumer<HttpHeaders> headersTransformer,
74+
Function<HttpHeaders, Mono<? extends HttpHeaders>> headersWhenTransformer) {
75+
return createOperator()
76+
.flatMap(operator -> operator.headers(headers -> addHeaders(headers, requestPayload, headersTransformer)).headersWhen(headersWhenTransformer)
77+
.get()
78+
.uri(queryTransformer(requestPayload).andThen(uriTransformer))
79+
.response()
80+
.get());
81+
}
82+
7383
protected final <T> Mono<T> get(Object requestPayload, Class<T> responseType, Function<UriComponentsBuilder, UriComponentsBuilder> uriTransformer) {
7484
return createOperator()
7585
.flatMap(operator -> operator.headers(headers -> addHeaders(headers, requestPayload))

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/uaa/authorizations/ReactorAuthorizations.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,18 @@ public Mono<String> authorizationCodeGrantApi(AuthorizeByAuthorizationCodeGrantA
7474

7575
@Override
7676
public Mono<String> authorizationCodeGrantBrowser(AuthorizeByAuthorizationCodeGrantBrowserRequest request) {
77-
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.CODE), ReactorAuthorizations::removeAuthorization)
77+
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.CODE),
78+
outbound -> {},
79+
ReactorAuthorizations::removeAuthorization)
7880
.map(inbound -> inbound.responseHeaders().get(LOCATION))
7981
.checkpoint();
8082
}
8183

8284
@Override
8385
public Mono<String> authorizationCodeGrantHybrid(AuthorizeByAuthorizationCodeGrantHybridRequest request) {
84-
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.CODE_AND_ID_TOKEN), ReactorAuthorizations::removeAuthorization)
86+
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.CODE_AND_ID_TOKEN),
87+
outbound -> {},
88+
ReactorAuthorizations::removeAuthorization)
8589
.map(inbound -> inbound.responseHeaders().get(LOCATION))
8690
.checkpoint();
8791
}
@@ -94,14 +98,18 @@ public Mono<GetOpenIdProviderConfigurationResponse> getOpenIdProviderConfigurati
9498

9599
@Override
96100
public Mono<String> implicitGrantBrowser(AuthorizeByImplicitGrantBrowserRequest request) {
97-
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.TOKEN), ReactorAuthorizations::removeAuthorization)
101+
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.TOKEN),
102+
outbound -> {},
103+
ReactorAuthorizations::removeAuthorization)
98104
.map(inbound -> inbound.responseHeaders().get(LOCATION))
99105
.checkpoint();
100106
}
101107

102108
@Override
103109
public Mono<String> openIdWithAuthorizationCodeAndIdToken(AuthorizeByOpenIdWithAuthorizationCodeGrantRequest request) {
104-
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.CODE_AND_ID_TOKEN), ReactorAuthorizations::removeAuthorization)
110+
return get(request, builder -> builder.pathSegment("oauth", "authorize").queryParam("response_type", ResponseType.CODE_AND_ID_TOKEN),
111+
outbound -> {},
112+
ReactorAuthorizations::removeAuthorization)
105113
.map(inbound -> inbound.responseHeaders().get(LOCATION))
106114
.checkpoint();
107115
}
@@ -120,8 +128,9 @@ public Mono<String> openIdWithTokenAndIdToken(AuthorizeByOpenIdWithImplicitGrant
120128
.checkpoint();
121129
}
122130

123-
private static void removeAuthorization(HttpHeaders httpHeaders) {
124-
httpHeaders.remove(AUTHORIZATION);
131+
private static Mono<HttpHeaders> removeAuthorization(HttpHeaders request) {
132+
return Mono.just(request.remove(AUTHORIZATION));
125133
}
126134

135+
127136
}

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/uaa/serverinformation/ReactorServerInformation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ public Mono<Void> autoLogin(AutoLoginRequest request) {
6060
@Override
6161
public Mono<GetAutoLoginAuthenticationCodeResponse> getAuthenticationCode(GetAutoLoginAuthenticationCodeRequest request) {
6262
return post(request, GetAutoLoginAuthenticationCodeResponse.class, builder -> builder.pathSegment("autologin"),
63+
outbound -> {
64+
},
6365
outbound -> {
6466
String encoded = Base64.getEncoder().encodeToString(new AsciiString(request.getClientId()).concat(":").concat(request.getClientSecret()).toByteArray());
6567
outbound.set(AUTHORIZATION, BASIC_PREAMBLE + encoded);
68+
69+
return Mono.just(outbound);
6670
})
6771
.checkpoint();
6872
}

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/uaa/serverinformation/ReactorInfoTest.java renamed to cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/uaa/serverinformation/ReactorServerInformationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import static io.netty.handler.codec.http.HttpResponseStatus.FOUND;
4242
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
4343

44-
public final class ReactorInfoTest extends AbstractUaaApiTest {
44+
public final class ReactorServerInformationTest extends AbstractUaaApiTest {
4545

4646
private final ReactorServerInformation info = new ReactorServerInformation(CONNECTION_CONTEXT, this.root, TOKEN_PROVIDER);
4747

integration-test/src/test/resources/logback-test.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<logger name="cloudfoundry-client.test" level="${TEST_LOGGING_LEVEL:-INFO}"/>
3333
<logger name="cloudfoundry-client.token" level="${CLIENT_LOGGING_LEVEL:-INFO}"/>
3434
<logger name="cloudfoundry-client.trust" level="${CLIENT_LOGGING_LEVEL:-WARN}"/>
35+
<logger name="cloudfoundry-client.wire" level="${CLIENT_LOGGING_LEVEL:-INFO}"/>
3536
<logger name="example" level="DEBUG"/>
3637
<logger name="reactor.netty" level="INFO"/>
3738
<logger name="stream" level="INFO"/>

0 commit comments

Comments
 (0)