Skip to content

Commit 3f408d8

Browse files
GRAD2-3282 - Apply client authentication to GRAD-STUDENT-GRADUATION-API
1 parent 2a2a8b0 commit 3f408d8

File tree

46 files changed

+1253
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1253
-294
lines changed

.github/workflows/build.from.developer.branch.deploy.to.dev.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ env:
1010
COMMON_NAMESPACE: ${{ secrets.COMMON_NAMESPACE }}
1111
NAMESPACE: ${{ secrets.GRAD_NAMESPACE }}
1212
BUSINESS_NAMESPACE: ${{ secrets.GRAD_BUSINESS_NAMESPACE }}
13+
KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }}
14+
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
15+
TARGET_ENV: dev
1316

1417
# 🖊️ EDIT to change the image registry settings.
1518
# Registries such as GHCR, Quay.io, and Docker Hub are supported.
@@ -95,6 +98,20 @@ jobs:
9598
username: ${{ env.IMAGE_REGISTRY_USER }}
9699
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
97100

101+
- name: Setup Node.js
102+
uses: actions/setup-node@v3
103+
with:
104+
node-version: '20'
105+
106+
- name: Install dependencies
107+
run: npm install axios
108+
109+
- name: Create/Update clients
110+
run: node ./tools/config/clients-and-scopes.js
111+
112+
- name: Create/Update secrets
113+
run: node ./tools/openshift/fetch-and-create-secrets.js
114+
98115
# The path the image was pushed to is now stored in ${{ steps.push-image.outputs.registry-path }}
99116
- name: Install oc
100117
uses: redhat-actions/openshift-tools-installer@v1

.github/workflows/build.from.main.branch.deploy.to.dev.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ env:
1010
COMMON_NAMESPACE: ${{ vars.COMMON_NAMESPACE }}
1111
GRAD_NAMESPACE: ${{ vars.GRAD_NAMESPACE }}
1212
BUSINESS_NAMESPACE: ${{ vars.GRAD_BUSINESS_NAMESPACE }}
13+
KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }}
14+
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
15+
TARGET_ENV: dev
1316

1417
# 🖊️ EDIT to change the image registry settings.
1518
# Registries such as GHCR, Quay.io, and Docker Hub are supported.
@@ -81,6 +84,20 @@ jobs:
8184
username: ${{ env.IMAGE_REGISTRY_USER }}
8285
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
8386

87+
- name: Setup Node.js
88+
uses: actions/setup-node@v3
89+
with:
90+
node-version: '20'
91+
92+
- name: Install dependencies
93+
run: npm install axios
94+
95+
- name: Create/Update clients
96+
run: node ./tools/config/clients-and-scopes.js
97+
98+
- name: Create/Update secrets
99+
run: node ./tools/openshift/fetch-and-create-secrets.js
100+
84101
# The path the image was pushed to is now stored in ${{ steps.push-image.outputs.registry-path }}
85102
- name: Install oc
86103
uses: redhat-actions/openshift-tools-installer@v1

.github/workflows/build.from.release.branch.deploy.to.dev.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ env:
1010
COMMON_NAMESPACE: ${{ vars.COMMON_NAMESPACE }}
1111
GRAD_NAMESPACE: ${{ vars.GRAD_NAMESPACE }}
1212
BUSINESS_NAMESPACE: ${{ vars.GRAD_BUSINESS_NAMESPACE }}
13+
KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }}
14+
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
15+
TARGET_ENV: dev
1316

1417
# 🖊️ EDIT to change the image registry settings.
1518
# Registries such as GHCR, Quay.io, and Docker Hub are supported.
@@ -89,6 +92,20 @@ jobs:
8992
username: ${{ env.IMAGE_REGISTRY_USER }}
9093
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
9194

95+
- name: Setup Node.js
96+
uses: actions/setup-node@v3
97+
with:
98+
node-version: '20'
99+
100+
- name: Install dependencies
101+
run: npm install axios
102+
103+
- name: Create/Update clients
104+
run: node ./tools/config/clients-and-scopes.js
105+
106+
- name: Create/Update secrets
107+
run: node ./tools/openshift/fetch-and-create-secrets.js
108+
92109
# The path the image was pushed to is now stored in ${{ steps.push-image.outputs.registry-path }}
93110
- name: Install oc
94111
uses: redhat-actions/openshift-tools-installer@v1

.github/workflows/deploy_latest_to_test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ env:
99
OPENSHIFT_NAMESPACE: ${{ vars.GRAD_NAMESPACE }}-test
1010
COMMON_NAMESPACE: ${{ vars.COMMON_NAMESPACE }}
1111
BUSINESS_NAMESPACE: ${{ vars.GRAD_BUSINESS_NAMESPACE }}
12+
KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }}
13+
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
14+
TARGET_ENV: test
1215

1316
SPRING_BOOT_IMAGE_NAME: educ-grad-student-graduation-api
1417

@@ -38,6 +41,20 @@ jobs:
3841
- name: Check out repository
3942
uses: actions/checkout@v4
4043

44+
- name: Setup Node.js
45+
uses: actions/setup-node@v3
46+
with:
47+
node-version: '20'
48+
49+
- name: Install dependencies
50+
run: npm install axios
51+
52+
- name: Create/Update clients
53+
run: node ./tools/config/clients-and-scopes.js
54+
55+
- name: Create/Update secrets
56+
run: node ./tools/openshift/fetch-and-create-secrets.js
57+
4158
- name: Install oc
4259
uses: redhat-actions/openshift-tools-installer@v1
4360
with:

.github/workflows/deploy_prod.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ env:
99
OPENSHIFT_NAMESPACE: ${{ vars.GRAD_NAMESPACE }}-prod
1010
COMMON_NAMESPACE: ${{ vars.COMMON_NAMESPACE }}
1111
BUSINESS_NAMESPACE: ${{ vars.GRAD_BUSINESS_NAMESPACE }}
12+
KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }}
13+
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
14+
TARGET_ENV: prod
1215

1316
SPRING_BOOT_IMAGE_NAME: educ-grad-student-graduation-api
1417

@@ -42,6 +45,20 @@ jobs:
4245
uses: actions-ecosystem/action-get-latest-tag@v1
4346
id: get-latest-tag
4447

48+
- name: Setup Node.js
49+
uses: actions/setup-node@v3
50+
with:
51+
node-version: '20'
52+
53+
- name: Install dependencies
54+
run: npm install axios
55+
56+
- name: Create/Update clients
57+
run: node ./tools/config/clients-and-scopes.js
58+
59+
- name: Create/Update secrets
60+
run: node ./tools/openshift/fetch-and-create-secrets.js
61+
4562
- name: Install oc
4663
uses: redhat-actions/openshift-tools-installer@v1
4764
with:
@@ -75,7 +92,7 @@ jobs:
7592
-p MAX_MEM=${{ env.MAX_MEM }} | oc apply -f -
7693
7794
# UPDATE Configmaps
78-
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-configmap.sh \
95+
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ steps.get-latest-tag.outputs.tag }}/tools/config/update-configmap.sh \
7996
| bash /dev/stdin \
8097
prod \
8198
${{ env.REPO_NAME }} \

.github/workflows/deploy_test.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ env:
99
OPENSHIFT_NAMESPACE: ${{ vars.GRAD_NAMESPACE }}-test
1010
COMMON_NAMESPACE: ${{ vars.COMMON_NAMESPACE }}
1111
BUSINESS_NAMESPACE: ${{ vars.GRAD_BUSINESS_NAMESPACE }}
12+
KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }}
13+
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
14+
TARGET_ENV: test
1215

1316
SPRING_BOOT_IMAGE_NAME: educ-grad-student-graduation-api
1417

@@ -42,6 +45,20 @@ jobs:
4245
uses: actions-ecosystem/action-get-latest-tag@v1
4346
id: get-latest-tag
4447

48+
- name: Setup Node.js
49+
uses: actions/setup-node@v3
50+
with:
51+
node-version: '20'
52+
53+
- name: Install dependencies
54+
run: npm install axios
55+
56+
- name: Create/Update clients
57+
run: node ./tools/config/clients-and-scopes.js
58+
59+
- name: Create/Update secrets
60+
run: node ./tools/openshift/fetch-and-create-secrets.js
61+
4562
- name: Install oc
4663
uses: redhat-actions/openshift-tools-installer@v1
4764
with:
@@ -75,7 +92,7 @@ jobs:
7592
-p MAX_MEM=${{ env.MAX_MEM }} | oc apply -f -
7693
7794
# UPDATE Configmaps
78-
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-configmap.sh \
95+
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ steps.get-latest-tag.outputs.tag }}/tools/config/update-configmap.sh \
7996
| bash /dev/stdin \
8097
test \
8198
${{ env.REPO_NAME }} \

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ build/
5555
.vscode/
5656

5757
### Local dev ###
58-
**/application-local.yaml
58+
**/application-local.yaml
59+
**/generate-local-env.sh

api/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
<groupId>org.springframework.boot</groupId>
6969
<artifactId>spring-boot-starter-data-jpa</artifactId>
7070
</dependency>
71+
<dependency>
72+
<groupId>org.springframework.boot</groupId>
73+
<artifactId>spring-boot-starter-validation</artifactId>
74+
</dependency>
7175
<!-- GRAD2-1899, getting rid of spring security dependency to upgrade api to spring boot 3.0.2-->
7276
<dependency>
7377
<groupId>org.apache.logging.log4j</groupId>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
package ca.bc.gov.educ.api.studentgraduation.config;
22

3+
import lombok.extern.slf4j.Slf4j;
34
import org.flywaydb.core.Flyway;
45
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
67
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
78
import org.springframework.stereotype.Component;
89

10+
@Slf4j
911
@Component
1012
public class FlywayMigrationStrategyImpl implements FlywayMigrationStrategy {
1113

12-
private static Logger logger = LoggerFactory.getLogger(FlywayMigrationStrategyImpl.class);
13-
1414
@Override
1515
public void migrate(Flyway flyway) {
1616
if (!flyway.validateWithResult().validationSuccessful) {
1717
flyway.repair();
1818
}
19-
logger.info("\n");
20-
logger.info("************FLYWAY-MIGRATE**********");
19+
log.info("\n");
20+
log.info("************FLYWAY-MIGRATE**********");
2121
flyway.migrate();
22-
logger.info("************FLYWAY-MIGRATE-END**********\n\n");
22+
log.info("************FLYWAY-MIGRATE-END**********\n\n");
2323
}
2424
}

api/src/main/java/ca/bc/gov/educ/api/studentgraduation/config/GradStudentGraduationConfig.java

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@
22

33
import ca.bc.gov.educ.api.studentgraduation.util.EducGradStudentGraduationApiConstants;
44
import ca.bc.gov.educ.api.studentgraduation.util.LogHelper;
5-
import ca.bc.gov.educ.api.studentgraduation.util.ThreadLocalStateUtil;
65
import org.modelmapper.ModelMapper;
76
import org.springframework.beans.factory.annotation.Autowired;
8-
import org.springframework.boot.web.client.RestTemplateBuilder;
97
import org.springframework.context.annotation.Bean;
108
import org.springframework.context.annotation.Configuration;
11-
import org.springframework.web.client.RestTemplate;
12-
import org.springframework.web.reactive.function.client.ClientRequest;
13-
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
14-
import org.springframework.web.reactive.function.client.WebClient;
15-
import reactor.netty.http.client.HttpClient;
169

1710
@Configuration
1811
public class GradStudentGraduationConfig {
@@ -28,50 +21,6 @@ public GradStudentGraduationConfig(EducGradStudentGraduationApiConstants constan
2821

2922
@Bean
3023
public ModelMapper modelMapper() {
31-
32-
ModelMapper modelMapper = new ModelMapper();
33-
//modelMapper.typeMap(GradProgramEntity.class, GradProgram.class);
34-
//modelMapper.typeMap(GradProgram.class, GradProgramEntity.class);
35-
return modelMapper;
36-
}
37-
38-
@Bean
39-
public WebClient webClient() {
40-
HttpClient client = HttpClient.create();
41-
client.warmup().block();
42-
return WebClient.builder()
43-
.filter(setRequestHeaders())
44-
.filter(this.log())
45-
.build();
46-
}
47-
48-
@Bean
49-
public RestTemplate restTemplate(RestTemplateBuilder builder) {
50-
return builder.build();
51-
}
52-
53-
private ExchangeFilterFunction setRequestHeaders() {
54-
return (clientRequest, next) -> {
55-
ClientRequest modifiedRequest = ClientRequest.from(clientRequest)
56-
.header(EducGradStudentGraduationApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID())
57-
.header(EducGradStudentGraduationApiConstants.USER_NAME, ThreadLocalStateUtil.getCurrentUser())
58-
.header(EducGradStudentGraduationApiConstants.REQUEST_SOURCE, EducGradStudentGraduationApiConstants.API_NAME)
59-
.build();
60-
return next.exchange(modifiedRequest);
61-
};
24+
return new ModelMapper();
6225
}
63-
64-
private ExchangeFilterFunction log() {
65-
return (clientRequest, next) -> next
66-
.exchange(clientRequest)
67-
.doOnNext((clientResponse -> logHelper.logClientHttpReqResponseDetails(
68-
clientRequest.method(),
69-
clientRequest.url().toString(),
70-
clientResponse.statusCode().value(),
71-
clientRequest.headers().get(EducGradStudentGraduationApiConstants.CORRELATION_ID),
72-
clientRequest.headers().get(EducGradStudentGraduationApiConstants.REQUEST_SOURCE),
73-
constants.isSplunkLogHelperEnabled())
74-
));
75-
}
76-
7726
}

0 commit comments

Comments
 (0)