Skip to content
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

FDP-94: Add option to not use organisation certificates #7

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,19 @@ public void handleRequest(
}

String organisationName = null;
if (request.getAttribute(DEFAULT_REQUEST_ATTR_NAME)
instanceof final SecurityContext securityContext
&& securityContext.getAuthentication().getPrincipal() instanceof final User organisation) {
organisationName = organisation.getUsername();
}
if (organisationName == null) {
LOGGER.error("Unable to find client certificate, returning 500.");
createErrorResponse(response);
return;
if(soapConfiguration.getUseOrganisationFromRequest()) {
if (request.getAttribute(DEFAULT_REQUEST_ATTR_NAME)
instanceof final SecurityContext securityContext
&& securityContext.getAuthentication().getPrincipal() instanceof final User organisation) {
organisationName = organisation.getUsername();
}
if (organisationName == null) {
LOGGER.error("Unable to find client certificate, returning 500.");
createErrorResponse(response);
return;
}
} else {
organisationName = "";
}

// Cache the incoming connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ class SoapConfigurationProperties(
* Timeouts for specific functions.
*/
val customTimeouts: Map<String, Int> = emptyMap(),
/**
* TODO Can we search for certificates on both sides
*
* Property to set common name based on the organisation on requests published to Kafka.
*
* If set to false the other listening proxy doesn't search for certificates by [org.gxf.soapbridge.valueobjects.ProxyServerRequestMessage.commonName].
* Instead, the other proxy will generate a new ssl context.
*/
val useOrganisationFromRequest: Boolean = true,
val callEndpoint: SoapEndpointConfiguration,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SoapClientTest {
HostnameVerificationStrategy.BROWSER_COMPATIBLE_HOSTNAMES,
45,
new HashMap<>(),
true,
new SoapEndpointConfiguration("localhost", 443, "https"));

@InjectMocks SoapClient soapClient;
Expand All @@ -61,7 +62,7 @@ void shouldSendSoapRequestAndKafkaResponse() throws Exception {
}

@Test
void shoudDisconnectWhenSoapRequestFails() throws Exception {
void shouldDisconnectWhenSoapRequestFails() throws Exception {
// arrange
final HttpsURLConnection connection = setupFailingConnectionMock();
Mockito.when(
Expand Down
Loading