Skip to content

Commit

Permalink
Po 64 add basic auth to legacy gateway service (#194)
Browse files Browse the repository at this point in the history
* update schemas, update defendantaccount details service to retrieve notes

* Add legacy gateway basic auth

* Bumping chart version/ fixing aliases

---------

Co-authored-by: hmcts-jenkins-cnp <60659747+hmcts-jenkins-cnp[bot]@users.noreply.github.com>
  • Loading branch information
DeclanClarkeCGI and hmcts-jenkins-cnp[bot] authored Feb 13, 2024
1 parent afb305e commit 30c43c5
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 23 deletions.
2 changes: 1 addition & 1 deletion charts/opal-fines-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: "1.0"
description: A Helm chart for opal-fines-service app
name: opal-fines-service
home: https://github.com/hmcts/opal-fines-service
version: 0.0.25
version: 0.0.26
maintainers:
- name: HMCTS Opal Team
dependencies:
Expand Down
6 changes: 5 additions & 1 deletion charts/opal-fines-service/values.dev.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ java:
alias: AAD_CLIENT_ID
- name: AzureADClientSecret
alias: AAD_CLIENT_SECRET
- name: OpalLegacyGatewayUsername
alias: OPAL_LEGACY_GATEWAY_USERNAME
- name: OpalLegacyGatewayPassword
alias: OPAL_LEGACY_GATEWAY_PASSWORD
environment:
OPAL_FINES_DB_HOST: "{{ .Release.Name }}-postgresql"
OPAL_FINES_DB_NAME: "{{ .Values.postgresql.auth.database}}"
Expand All @@ -22,7 +26,7 @@ java:
OPAL_FINES_DB_PORT: 5432
RUN_DB_MIGRATION_ON_STARTUP: true
OPAL_FRONTEND_URL: https://opal-frontend.staging.platform.hmcts.net
OPAL_LEGACY_GATEWAY_URL: https://opal-legacy-db-stub.staging.platform.hmcts.net
OPAL_LEGACY_GATEWAY_URL: https://opal.clouddev.online/opal
TESTING_SUPPORT_ENDPOINTS_ENABLED: true
postgresql:
enabled: true
4 changes: 4 additions & 0 deletions charts/opal-fines-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ java:
alias: AAD_CLIENT_SECRET
- name: OpalTestUserPassword
alias: OPAL_TEST_USER_PASSWORD
- name: OpalLegacyGatewayUsername
alias: OPAL_LEGACY_GATEWAY_USERNAME
- name: OpalLegacyGatewayPassword
alias: OPAL_LEGACY_GATEWAY_PASSWORD
environment:
RUN_DB_MIGRATION_ON_STARTUP: true
OPAL_FRONTEND_URL: https://opal-frontend.{{ .Values.global.environment }}.platform.hmcts.net
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
package uk.gov.hmcts.opal.config.rest;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.client.RestClient;

import java.util.Base64;

@Configuration
public class RestClientConfiguration {

@Value("${legacy-gateway.username}")
String legacyUsername;

@Value("${legacy-gateway.password}")
String legacyPassword;

@Bean
public RestClient restClient() {
return RestClient.create();
}

@Bean RestClient legacyRestClient() {
return RestClient.builder()
.defaultHeader(
HttpHeaders.AUTHORIZATION,
encodeBasic(legacyUsername,
legacyPassword)
).build();
}

private String encodeBasic(String username, String password) {
return "Basic " + Base64
.getEncoder()
.encodeToString((username + ":" + password).getBytes());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyAccountTransferService extends LegacyService implements AccountTransferServiceInterface {

@Autowired
protected LegacyAccountTransferService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyAccountTransferService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyBusinessUnitService extends LegacyService implements BusinessUnitServiceInterface {

@Autowired
protected LegacyBusinessUnitService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyBusinessUnitService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class LegacyCommittalWarrantProgressService extends LegacyService
implements CommittalWarrantProgressServiceInterface {

@Autowired
protected LegacyCommittalWarrantProgressService(@Value("${legacy-gateway-url}") String gatewayUrl,
protected LegacyCommittalWarrantProgressService(@Value("${legacy-gateway.url}") String gatewayUrl,
RestClient restClient) {
super(gatewayUrl, restClient);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyCourtService extends LegacyService implements CourtServiceInterface {

@Autowired
protected LegacyCourtService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyCourtService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyDebtorDetailService extends LegacyService implements DebtorDetailServiceInterface {

@Autowired
protected LegacyDebtorDetailService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyDebtorDetailService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class LegacyDefendantAccountService extends LegacyService implements Defe
public static final String GET_ACCOUNT_DETAILS = "getAccountDetails";

@Autowired
protected LegacyDefendantAccountService(@Value("${legacy-gateway-url}") String gatewayUrl,
RestClient restClient) {
super(gatewayUrl, restClient);
protected LegacyDefendantAccountService(@Value("${legacy-gateway.url}") String gatewayUrl,
RestClient legacyRestClient) {
super(gatewayUrl, legacyRestClient);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyDocumentInstanceService extends LegacyService implements DocumentInstanceServiceInterface {

@Autowired
protected LegacyDocumentInstanceService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyDocumentInstanceService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyDocumentService extends LegacyService implements DocumentServiceInterface {

@Autowired
protected LegacyDocumentService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyDocumentService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyEnforcementService extends LegacyService implements EnforcementServiceInterface {

@Autowired
protected LegacyEnforcementService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyEnforcementService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyEnforcerService extends LegacyService implements EnforcerServiceInterface {

@Autowired
protected LegacyEnforcerService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyEnforcerService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyLocalJusticeAreaService extends LegacyService implements LocalJusticeAreaServiceInterface {

@Autowired
protected LegacyLocalJusticeAreaService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyLocalJusticeAreaService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyMisDebtorService extends LegacyService implements MisDebtorServiceInterface {

@Autowired
protected LegacyMisDebtorService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyMisDebtorService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class LegacyNoteService extends LegacyService implements NoteServiceInter

public static final String POST_ACCOUNT_NOTES = "postAccountNotes";

protected LegacyNoteService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyNoteService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class LegacyPartyService extends LegacyService implements PartyServiceInt
public static final String POST_PARTY = "postParty";

@Autowired
protected LegacyPartyService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyPartyService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyPaymentInService extends LegacyService implements PaymentInServiceInterface {

@Autowired
protected LegacyPaymentInService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyPaymentInService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyPaymentTermsService extends LegacyService implements PaymentTermsServiceInterface {

@Autowired
protected LegacyPaymentTermsService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyPaymentTermsService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyPrisonService extends LegacyService implements PrisonServiceInterface {

@Autowired
protected LegacyPrisonService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyPrisonService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class LegacyTillService extends LegacyService implements TillServiceInterface {

@Autowired
protected LegacyTillService(@Value("${legacy-gateway-url}") String gatewayUrl, RestClient restClient) {
protected LegacyTillService(@Value("${legacy-gateway.url}") String gatewayUrl, RestClient restClient) {
super(gatewayUrl, restClient);
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ azure:

app-mode: opal

legacy-gateway-url: ${OPAL_LEGACY_GATEWAY_URL:http://localhost:4553/opal}
legacy-gateway:
url: ${OPAL_LEGACY_GATEWAY_URL:http://localhost:4553/opal}
username: ${OPAL_LEGACY_GATEWAY_USERNAME:username}
password: ${OPAL_LEGACY_GATEWAY_PASSWORD:password}

launchdarkly:
sdk-key: ${LAUNCH_DARKLY_SDK_KEY:}
Expand Down

0 comments on commit 30c43c5

Please sign in to comment.