diff --git a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
index c13c46c1..89cae1fd 100644
--- a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
@@ -29,6 +29,7 @@ env:
MAX_MEM: "1500Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "7"
+ SOAM_KC_REALM_ID: "master"
on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
@@ -145,6 +146,16 @@ jobs:
${{ env.BUSINESS_NAMESPACE }} \
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
+
+ # UPDATE KC Client
+ curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
+ | bash /dev/stdin \
+ dev \
+ ${{ env.COMMON_NAMESPACE }} \
+ ${{ env.SOAM_KC_REALM_ID }} \
+ ${{ secrets.CLIENT_ID }} \
+ ${{ env.BRANCH }} \
+ ${{ env.REPO_NAME }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
diff --git a/.github/workflows/build.from.main.branch.deploy.to.dev.yml b/.github/workflows/build.from.main.branch.deploy.to.dev.yml
index fb5ef3e5..b81ace7f 100644
--- a/.github/workflows/build.from.main.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.main.branch.deploy.to.dev.yml
@@ -29,6 +29,7 @@ env:
MAX_MEM: "1500Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "7"
+ SOAM_KC_REALM_ID: "master"
on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
@@ -127,6 +128,16 @@ jobs:
${{ env.BUSINESS_NAMESPACE }} \
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
+
+ # UPDATE KC Client
+ curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
+ | bash /dev/stdin \
+ dev \
+ ${{ env.COMMON_NAMESPACE }} \
+ ${{ env.SOAM_KC_REALM_ID }} \
+ ${{ secrets.CLIENT_ID }} \
+ ${{ env.BRANCH }} \
+ ${{ env.REPO_NAME }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
diff --git a/.github/workflows/build.from.release.branch.deploy.to.dev.yml b/.github/workflows/build.from.release.branch.deploy.to.dev.yml
index 82d03e56..ab09e3a3 100644
--- a/.github/workflows/build.from.release.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.release.branch.deploy.to.dev.yml
@@ -28,6 +28,7 @@ env:
MAX_MEM: "1500Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "7"
+ SOAM_KC_REALM_ID: "master"
on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
@@ -134,6 +135,16 @@ jobs:
${{ env.BUSINESS_NAMESPACE }} \
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
+
+ # UPDATE KC Client
+ curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
+ | bash /dev/stdin \
+ dev \
+ ${{ env.COMMON_NAMESPACE }} \
+ ${{ env.SOAM_KC_REALM_ID }} \
+ ${{ secrets.CLIENT_ID }} \
+ ${{ env.BRANCH }} \
+ ${{ env.REPO_NAME }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml
index 7c3a3839..101357b6 100644
--- a/.github/workflows/deploy_prod.yml
+++ b/.github/workflows/deploy_prod.yml
@@ -23,6 +23,7 @@ env:
MAX_MEM: "1500Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "7"
+ SOAM_KC_REALM_ID: "master"
on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
@@ -83,6 +84,16 @@ jobs:
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
+ # UPDATE KC Client
+ curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
+ | bash /dev/stdin \
+ dev \
+ ${{ env.COMMON_NAMESPACE }} \
+ ${{ env.SOAM_KC_REALM_ID }} \
+ ${{ secrets.CLIENT_ID }} \
+ ${{ env.BRANCH }} \
+ ${{ env.REPO_NAME }}
+
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
|| true && echo "Rollout in progress"
diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml
index b6110d15..88a5c595 100644
--- a/.github/workflows/deploy_test.yml
+++ b/.github/workflows/deploy_test.yml
@@ -23,6 +23,7 @@ env:
MAX_MEM: "1500Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "7"
+ SOAM_KC_REALM_ID: "master"
on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
@@ -83,6 +84,16 @@ jobs:
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
+ # UPDATE KC Client
+ curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
+ | bash /dev/stdin \
+ dev \
+ ${{ env.COMMON_NAMESPACE }} \
+ ${{ env.SOAM_KC_REALM_ID }} \
+ ${{ secrets.CLIENT_ID }} \
+ ${{ env.BRANCH }} \
+ ${{ env.REPO_NAME }}
+
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
|| true && echo "Rollout in progress"
diff --git a/api/pom.xml b/api/pom.xml
index 28b90f83..463b5867 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
ca.bc.gov.educ
educ-grad-graduation-api
- 1.8.55
+ 1.8.56
educ-grad-graduation-api
Ministry of Education GRAD GRADUATION API
diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java
index 61acb3d3..a8deb96a 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/config/RestWebClient.java
@@ -7,6 +7,13 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
+import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager;
+import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProvider;
+import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProviderBuilder;
+import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
+import org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizedClientManager;
+import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository;
+import org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
@@ -18,20 +25,48 @@
@Profile("!test")
public class RestWebClient {
- @Autowired
EducGraduationApiConstants constants;
- @Autowired
LogHelper logHelper;
- private final HttpClient httpClient;
+ @Autowired
+ public RestWebClient(EducGraduationApiConstants constants, LogHelper logHelper) {
+ this.constants = constants;
+ this.logHelper = logHelper;
+ }
- public RestWebClient() {
- this.httpClient = HttpClient.create().compress(true)
- .resolver(spec -> spec.queryTimeout(Duration.ofMillis(200)).trace("DNS", LogLevel.TRACE));
- this.httpClient.warmup().block();
+ @Bean("graduationClient")
+ public WebClient getGraduationClientWebClient(OAuth2AuthorizedClientManager authorizedClientManager) {
+ ServletOAuth2AuthorizedClientExchangeFilterFunction filter = new ServletOAuth2AuthorizedClientExchangeFilterFunction(authorizedClientManager);
+ filter.setDefaultClientRegistrationId("graduationclient");
+ return WebClient.builder()
+ .exchangeStrategies(ExchangeStrategies
+ .builder()
+ .codecs(codecs -> codecs
+ .defaultCodecs()
+ .maxInMemorySize(50 * 1024 * 1024))
+ .build())
+ .apply(filter.oauth2Configuration())
+ .filter(this.log())
+ .build();
+ }
+ @Bean
+ public OAuth2AuthorizedClientManager authorizedClientManager(
+ ClientRegistrationRepository clientRegistrationRepository,
+ OAuth2AuthorizedClientRepository authorizedClientRepository) {
+ OAuth2AuthorizedClientProvider authorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder()
+ .clientCredentials()
+ .build();
+ DefaultOAuth2AuthorizedClientManager authorizedClientManager = new DefaultOAuth2AuthorizedClientManager(
+ clientRegistrationRepository, authorizedClientRepository);
+ authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider);
+ return authorizedClientManager;
}
+ /**
+ * Old web client. You can use a @Qualifier('default') to summon it.
+ * @return
+ */
@Bean
public WebClient webClient() {
return WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java
index 542197b0..c17c33bb 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java
@@ -131,8 +131,7 @@ public void restoreStudentGradStatus(String studentID, String accessToken,boolea
public List getStudentListByMinCode(String schoolOfRecord, String accessToken) {
List