Skip to content

Commit dcfc7d9

Browse files
committed
Merge branch 'stories/ECER-5315' of https://github.com/bcgov/ECC-ECER into stories/ECER-5315
2 parents c36be9e + 8af0641 commit dcfc7d9

File tree

173 files changed

+26037
-2110
lines changed

Some content is hidden

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

173 files changed

+26037
-2110
lines changed

.github/workflows/api-build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ on:
1010
- src/**
1111
- "!src/ECER.Clients.RegistryPortal/**"
1212
- "!src/ECER.Clients.E2ETestData/**"
13+
- "!src/ECER.Clients.PSPPortal/**"
1314
- "!src/registry-portal.Dockerfile"
1415
- "!src/e2e-test-data.Dockerfile"
16+
- "!src/psp-portal.Dockerfile"
1517
- .github/workflows/api-build.yml
1618
- .github/workflows/build-template.yml
1719

@@ -20,8 +22,10 @@ on:
2022
- src/**
2123
- "!src/ECER.Clients.RegistryPortal/**"
2224
- "!src/ECER.Clients.E2ETestData/**"
23-
- "!src/registry-portal.Dockerfile"
25+
- "!src/ECER.Clients.PSPPortal/**"
26+
- "!src/registry-portal.Dockerfile"
2427
- "!src/e2e-test-data.Dockerfile"
28+
- "!src/psp-portal.Dockerfile"
2529
- .github/workflows/api-build.yml
2630
- .github/workflows/build-template.yml
2731

.github/workflows/deploy-to-dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
5959
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} --alias=true registry-portal:${{github.event.inputs.version}} registry-portal:${{env.APP_ENVIRONMENT_DESTINATION}}
6060
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} --alias=true api:${{github.event.inputs.version}} api:${{env.APP_ENVIRONMENT_DESTINATION}}
61+
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} --alias=true psp-portal:${{github.event.inputs.version}} psp-portal:${{env.APP_ENVIRONMENT_DESTINATION}}
6162
6263
# E2ETestData only exists in Dev and is used for automation testing, this will not exist in higher environments.
6364
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} --alias=true e2e-test-data:${{github.event.inputs.version}} e2e-test-data:${{env.APP_ENVIRONMENT_DESTINATION}}

.github/workflows/deploy-to-prod.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ jobs:
5252
#grabs the image sha for our input environments using jq
5353
API_IMAGE_SHA=$(oc get is api -o json | jq -r '.spec.tags[] | select(.name == "${{inputs.app_environment_source}}").from.name')
5454
REGISTRY_PORTAL_IMAGE_SHA=$(oc get is registry-portal -o json | jq -r '.spec.tags[] | select(.name == "${{inputs.app_environment_source}}").from.name')
55+
# PSP_PORTAL_IMAGE_SHA=$(oc get is psp-portal -o json | jq -r '.spec.tags[] | select(.name == "${{inputs.app_environment_source}}").from.name')
5556
5657
echo registry-portal image sha being promoted: $REGISTRY_PORTAL_IMAGE_SHA
5758
echo api image sha being promoted: $API_IMAGE_SHA
59+
# echo psp-portal image sha being promoted: $PSP_PORTAL_IMAGE_SHA
5860
5961
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} registry-portal:${{inputs.app_environment_source}} registry-portal:${{env.APP_ENVIRONMENT_DESTINATION}}
6062
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} api:${{inputs.app_environment_source}} api:${{env.APP_ENVIRONMENT_DESTINATION}}
63+
# oc tag -n ${{env.OPENSHIFT_NAMESPACE}} psp-portal:${{inputs.app_environment_source}} psp-portal:${{env.APP_ENVIRONMENT_DESTINATION}}

.github/workflows/deploy-to-test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ jobs:
4545
#grabs the image sha for our input environments using jq
4646
API_IMAGE_SHA=$(oc get is api -o json | jq -r '.spec.tags[] | select(.name == "${{env.APP_ENVIRONMENT_SOURCE}}").from.name')
4747
REGISTRY_PORTAL_IMAGE_SHA=$(oc get is registry-portal -o json | jq -r '.spec.tags[] | select(.name == "${{env.APP_ENVIRONMENT_SOURCE}}").from.name')
48+
PSP_PORTAL_IMAGE_SHA=$(oc get is psp-portal -o json | jq -r '.spec.tags[] | select(.name == "${{inputs.app_environment_source}}").from.name')
4849
4950
echo registry-portal image sha being promoted: $REGISTRY_PORTAL_IMAGE_SHA
5051
echo api image sha being promoted: $API_IMAGE_SHA
52+
echo psp-portal image sha being promoted: $PSP_PORTAL_IMAGE_SHA
5153
5254
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} registry-portal:${{env.APP_ENVIRONMENT_SOURCE}} registry-portal:${{env.APP_ENVIRONMENT_DESTINATION}}
5355
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} api:${{env.APP_ENVIRONMENT_SOURCE}} api:${{env.APP_ENVIRONMENT_DESTINATION}}
56+
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} psp-portal:${{env.APP_ENVIRONMENT_SOURCE}} psp-portal:${{env.APP_ENVIRONMENT_DESTINATION}}

.github/workflows/deploy-to-uat.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ jobs:
4545
#grabs the image sha for our input environments using jq
4646
API_IMAGE_SHA=$(oc get is api -o json | jq -r '.spec.tags[] | select(.name == "${{env.APP_ENVIRONMENT_SOURCE}}").from.name')
4747
REGISTRY_PORTAL_IMAGE_SHA=$(oc get is registry-portal -o json | jq -r '.spec.tags[] | select(.name == "${{env.APP_ENVIRONMENT_SOURCE}}").from.name')
48+
PSP_PORTAL_IMAGE_SHA=$(oc get is psp-portal -o json | jq -r '.spec.tags[] | select(.name == "${{env.APP_ENVIRONMENT_SOURCE}}").from.name')
4849
4950
echo registry-portal image sha being promoted: $REGISTRY_PORTAL_IMAGE_SHA
5051
echo api image sha being promoted: $API_IMAGE_SHA
52+
echo psp-portal image sha being promoted: $PSP_PORTAL_IMAGE_SHA
5153
5254
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} registry-portal:${{env.APP_ENVIRONMENT_SOURCE}} registry-portal:${{env.APP_ENVIRONMENT_DESTINATION}}
5355
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} api:${{env.APP_ENVIRONMENT_SOURCE}} api:${{env.APP_ENVIRONMENT_DESTINATION}}
56+
oc tag -n ${{env.OPENSHIFT_NAMESPACE}} psp-portal:${{env.APP_ENVIRONMENT_SOURCE}} psp-portal:${{env.APP_ENVIRONMENT_DESTINATION}}

.github/workflows/e2e-test-data-build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ on:
1010
- src/**
1111
- "!src/ECER.Clients.RegistryPortal/**"
1212
- "!src/ECER.Clients.Api/**"
13+
- "!src/ECER.Clients.PSPPortal/**"
1314
- "!src/registry-portal.Dockerfile"
1415
- "!src/api.Dockerfile"
16+
- "!src/psp-portal.Dockerfile"
1517
- .github/workflows/e2e-test-data-build.yml
1618
- .github/workflows/build-template.yml
1719

@@ -20,9 +22,11 @@ on:
2022
- src/**
2123
- "!src/ECER.Clients.RegistryPortal/**"
2224
- "!src/ECER.Clients.Api/**"
25+
- "!src/ECER.Clients.PSPPortal/**"
2326
- "!src/registry-portal.Dockerfile"
2427
- "!src/api.Dockerfile"
25-
- .github/workflows/e2e-test-data-build.yml
28+
- "!src/psp-portal.Dockerfile"
29+
- .github/workflows/e2e-test-build.yml
2630
- .github/workflows/build-template.yml
2731

2832
jobs:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: PSP Portal Build
2+
on:
3+
workflow_dispatch:
4+
5+
push:
6+
branches:
7+
- master
8+
- "release/**"
9+
paths:
10+
- src/**
11+
- "!src/ECER.Clients.RegistryPortal/**"
12+
- "!src/ECER.Clients.Api/**"
13+
- "!src/ECER.Clients.E2ETestData/**"
14+
- "!src/registry-portal.Dockerfile"
15+
- "!src/api.Dockerfile"
16+
- "!src/e2e-test-data.Dockerfile"
17+
- .github/workflows/psp-portal-build.yml
18+
- .github/workflows/build-template.yml
19+
20+
pull_request:
21+
paths:
22+
- src/**
23+
- "!src/ECER.Clients.RegistryPortal/**"
24+
- "!src/ECER.Clients.Api/**"
25+
- "!src/ECER.Clients.E2ETestData/**"
26+
- "!src/registry-portal.Dockerfile"
27+
- "!src/api.Dockerfile"
28+
- "!src/e2e-test-data.Dockerfile"
29+
- .github/workflows/psp-portal-build.yml
30+
- .github/workflows/build-template.yml
31+
32+
jobs:
33+
build:
34+
permissions:
35+
contents: read
36+
packages: write
37+
id-token: write
38+
security-events: write
39+
uses: ./.github/workflows/build-template.yml
40+
with:
41+
IMAGE_CONTEXT: src
42+
IMAGE_FILE: src/psp-portal.Dockerfile
43+
IMAGE_NAME: psp-portal
44+
REGISTRY: ${{ vars.DOCKER_REGISTRY }}
45+
secrets:
46+
REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }}
47+
REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/registry-portal-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ on:
1010
- src/**
1111
- "!src/ECER.Clients.Api/**"
1212
- "!src/ECER.Clients.E2ETestData/**"
13+
- "!src/ECER.Clients.PSPPortal/**"
1314
- "!src/api.Dockerfile"
1415
- "!src/e2e-test-data.Dockerfile"
16+
- "!src/psp-portal.Dockerfile"
1517
- .github/workflows/registry-portal-build.yml
1618
- .github/workflows/build-template.yml
1719

@@ -20,8 +22,10 @@ on:
2022
- src/**
2123
- "!src/ECER.Clients.Api/**"
2224
- "!src/ECER.Clients.E2ETestData/**"
25+
- "!src/ECER.Clients.PSPPortal/**"
2326
- "!src/api.Dockerfile"
2427
- "!src/e2e-test-data.Dockerfile"
28+
- "!src/psp-portal.Dockerfile"
2529
- .github/workflows/registry-portal-build.yml
2630
- .github/workflows/build-template.yml
2731

.github/workflows/tag-create.git.and.imagestream.tag.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,34 @@ jobs:
9696
REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }}
9797
REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
9898

99+
build-psp-portal:
100+
needs: validate-input
101+
permissions:
102+
contents: read
103+
packages: write
104+
id-token: write
105+
security-events: write
106+
uses: ./.github/workflows/build-template.yml
107+
with:
108+
IMAGE_CONTEXT: src
109+
IMAGE_FILE: src/psp-portal.Dockerfile
110+
IMAGE_NAME: psp-portal
111+
REGISTRY: ${{ vars.DOCKER_REGISTRY }}
112+
secrets:
113+
REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }}
114+
REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
115+
99116
git-tag:
100117
name: Tag image
101118
runs-on: ubuntu-22.04
102119
needs:
103-
[validate-input, build-api, build-registry-portal, build-e2e-test-data]
120+
[
121+
validate-input,
122+
build-api,
123+
build-registry-portal,
124+
build-e2e-test-data,
125+
build-psp-portal,
126+
]
104127
environment: dev
105128

106129
steps:
@@ -110,8 +133,6 @@ jobs:
110133
- name: Create tag
111134
uses: actions/github-script@v7
112135
with:
113-
# we need to use a PAT token instead of the GITHUB_TOKEN to be able to create a tag that will trigger events.
114-
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
115136
script: |
116137
console.log(`this action was run on branch :: ${context.ref}`);
117138
console.log(`Github SHA :: ${context.sha}`);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using ECER.Clients.PSPPortal.Server.Shared;
2+
using ECER.Managers.Registry.Contract.Registrants;
3+
using ECER.Utilities.Security;
4+
using MediatR;
5+
using Microsoft.Extensions.Caching.Distributed;
6+
using Microsoft.Extensions.Options;
7+
using System.Security.Claims;
8+
9+
namespace ECER.Clients.PSPPortal.Server;
10+
11+
public class AuthenticationService(IMediator messageBus, IDistributedCache cache, IOptions<ClaimCacheSettings> claimCacheSettings)
12+
{
13+
public async Task<ClaimsPrincipal?> EnrichUserSecurityContext(ClaimsPrincipal principal, CancellationToken ct)
14+
{
15+
ArgumentNullException.ThrowIfNull(principal);
16+
17+
var identityProvider = principal.FindFirst(RegistryPortalClaims.IdenityProvider)?.Value;
18+
var identityId = principal.FindFirst(ClaimTypes.Name)?.Value;
19+
20+
if (string.IsNullOrEmpty(identityProvider) || string.IsNullOrEmpty(identityId)) return principal;
21+
22+
// try and get the current user information
23+
var userClaims = await GetUserClaims(new UserIdentity(identityId, identityProvider), ct);
24+
25+
if (userClaims == null) return principal;
26+
27+
principal.AddIdentity(new ClaimsIdentity(userClaims));
28+
29+
return principal;
30+
}
31+
32+
private async Task<Claim[]?> GetUserClaims(UserIdentity userIdentity, CancellationToken ct)
33+
{
34+
// try to find the registrant
35+
var registrant = await cache.GetAsync($"userinfo:{userIdentity.UserId}@{userIdentity.IdentityProvider}",
36+
async ct => (await messageBus.Send(new SearchRegistrantQuery { ByUserIdentity = userIdentity }, ct)).Items.SingleOrDefault(),
37+
new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(claimCacheSettings.Value.CacheTimeInSeconds) },
38+
ct);
39+
40+
if (registrant == null) return null;
41+
42+
// add registrant claims
43+
var userId = new Claim("user_id", registrant.UserId);
44+
Claim verificationStatus = new Claim("verified", "");
45+
if (registrant.Profile.Status == StatusCode.Verified)
46+
{
47+
verificationStatus = new Claim("verified", "true");
48+
}
49+
else if (registrant.Profile.Status is StatusCode.Unverified or StatusCode.PendingforDocuments)
50+
{
51+
verificationStatus = new Claim("verified", "false");
52+
}
53+
54+
return [userId, verificationStatus];
55+
}
56+
}

0 commit comments

Comments
 (0)