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

feat(ssi): Issuer component re issuance of bpnl and membership credentials #239

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1365c5f
feat: Created the base structure for the renewal credential job
leandro-cavalcante Aug 1, 2024
d6aa4bb
feat: added the new renewal credential app to the project solution
leandro-cavalcante Aug 1, 2024
46bf75e
feat: Creation of the job renewal structure acceesing the database
leandro-cavalcante Aug 5, 2024
39a50d6
feat: Added new library to hold the common objects for the credential
leandro-cavalcante Aug 8, 2024
e80764f
feat: New service to handle the credential reissuance
leandro-cavalcante Aug 8, 2024
4352927
feat: Added new type and query for the issuer repository
leandro-cavalcante Aug 8, 2024
f348ef4
feat: Creation of new issuance repository and process to mark credent…
leandro-cavalcante Aug 9, 2024
bcd275c
feat: Added revocation process for reissued credentials.
leandro-cavalcante Aug 12, 2024
0055d01
feat: Added reissuance expiry settings, docker file and helm configur…
leandro-cavalcante Aug 12, 2024
b0fcc9a
feat: added credential settings to reissuance cronjob
leandro-cavalcante Aug 12, 2024
92c626c
fix: adding a correct format
leandro-cavalcante Aug 12, 2024
e2e53da
feat: added a new app settings for reissuance app
leandro-cavalcante Aug 12, 2024
39d47c5
feat: added a generic contex to issuer service buisiness logic
leandro-cavalcante Aug 12, 2024
93c3b9b
feat: added a general contex to business logic tests
leandro-cavalcante Aug 12, 2024
4280423
feat: Added process work tests for credential reissuance
leandro-cavalcante Aug 14, 2024
6c04b54
fix: correct the type of a mocked method
leandro-cavalcante Aug 14, 2024
31bd483
feat: Added tests for Reissuance service and default value for reissu…
leandro-cavalcante Aug 19, 2024
de7fb87
Merge branch 'eclipse-tractusx:main' into feat/CS-948-Issuer-Componen…
leandro-cavalcante Aug 19, 2024
1032a8a
Merge branch 'feat/CS-948-Issuer-Component-Re-issuance-of-BPNL-and-Me…
leandro-cavalcante Aug 19, 2024
60c8945
feat: Added process work tests for credential reissuance
leandro-cavalcante Aug 14, 2024
54a2a73
Merge branch 'feat/CS-948-Issuer-Component-Re-issuance-of-BPNL-and-Me…
leandro-cavalcante Aug 19, 2024
b9692e9
feat: added notification trigger for reissuanse when credential is re…
leandro-cavalcante Aug 20, 2024
5c1f484
feat: fixed the format style
leandro-cavalcante Aug 20, 2024
e823e3c
fix: removed unused imports
leandro-cavalcante Aug 20, 2024
8744628
fix: fixed style of the source files
leandro-cavalcante Aug 20, 2024
90ca841
fix: changed the format of source
leandro-cavalcante Aug 21, 2024
a8823ae
fix: removed unused variable
leandro-cavalcante Aug 21, 2024
c018245
fix: added ternary response
leandro-cavalcante Aug 21, 2024
fce37a1
feat(reissuance): adjust reissuance app
Phil91 Sep 2, 2024
107056e
Merge branch 'eclipse-tractusx:main' into feat/CS-948-Issuer-Componen…
leandro-cavalcante Sep 2, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ jobs:
push: true
tags: kind-registry:5000/credential-issuer-processes-worker:testing

- name: Build reissuance app
id: build-reissuance-app-image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile-credential-reissuance-app
push: true
tags: kind-registry:5000/credential-reissuance-app:testing

- name: Set up Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4
with:
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/credential-reissuance-app-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
###############################################################
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

name: Build Credential Reissuance App Image

on:
push:
paths:
# service and transitive paths
- 'src/**'
# workflow file
- '.github/workflows/credential-reissuance-app-docker.yml'
# dockerfile
- 'docker/Dockerfile-credential-reissuance-app'

branches:
- 'main'
workflow_dispatch:

env:
IMAGE_NAMESPACE: "tractusx"
IMAGE_NAME: "ssi-credential-reissuance-app"

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3.4.0

- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=main
type=raw,value=${{ github.sha }}

- name: Build and push Docker image
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6.3.0
with:
context: .
file: ./docker/Dockerfile-credential-reissuance-app
platforms: linux/amd64, linux/arm64
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# https://github.com/peter-evans/dockerhub-description
- name: Update Docker Hub description
if: github.event_name != 'pull_request'
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
repository: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}
readme-filepath: ./docker/notice-credential-reissuance-app.md
11 changes: 10 additions & 1 deletion .github/workflows/owasp-zap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ jobs:
file: ./docker/Dockerfile-credential-expiry-app
push: true
tags: kind-registry:5000/credential-expiry-app:testing


- name: Build Reissuance image
id: build-reissuance-image
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6.3.0
with:
context: .
file: ./docker/Dockerfile-credential-reissuance-app
push: true
tags: kind-registry:5000/credential-reissuance-app:testing

- name: Add bitnami repo
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ jobs:
- image: tractusx/ssi-credential-expiry-app
dockerfile: ./docker/Dockerfile-credential-expiry-app
dockernotice: ./docker/notice-credential-expiry-app.md
- image: tractusx/ssi-credential-reissuance-app
dockerfile: ./docker/Dockerfile-credential-reissuance-app
dockernotice: ./docker/notice-credential-reissuance-app.md
outputs:
app-version: ${{ steps.app-version.outputs.current }}
version-check: ${{ steps.version-check.outputs.exists }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- image: tractusx/ssi-credential-expiry-app
dockerfile: ./docker/Dockerfile-credential-expiry-app
dockernotice: ./docker/notice-credential-expiry-app.md
- image: tractusx/ssi-credential-reissuance-app
dockerfile: ./docker/Dockerfile-credential-reissuance-app
dockernotice: ./docker/notice-credential-reissuance-app.md
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/trivy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,36 @@ jobs:
uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
with:
sarif_file: "trivy-results5.sarif"

analyze-ssi-credential-issuer-reissuance-app:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# It's also possible to scan your private registry with Trivy's built-in image scan.
# All you have to do is set ENV vars.
# Docker Hub needs TRIVY_USERNAME and TRIVY_PASSWORD.
# You don't need to set ENV vars when downloading from a public repository.
# For public images, no ENV vars must be set.
- name: Run Trivy vulnerability scanner
if: always()
uses: aquasecurity/trivy-action@7c2007bcb556501da015201bcba5aa14069b74e2 # v0.23.0
with:
# Path to Docker image
image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-issuer-reissuance-app:main"
format: "sarif"
output: "trivy-results6.sarif"
vuln-type: "os,library"
skip-dirs: "docs/"

- name: Upload Trivy scan results to GitHub Security tab
if: always()
uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
with:
sarif_file: "trivy-results6.sarif"
32 changes: 32 additions & 0 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,35 @@ jobs:
uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
with:
sarif_file: "trivy-results5.sarif"

analyze-ssi-credential-reissuance-app:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# It's also possible to scan your private registry with Trivy's built-in image scan.
# All you have to do is set ENV vars.
# Docker Hub needs TRIVY_USERNAME and TRIVY_PASSWORD.
# You don't need to set ENV vars when downloading from a public repository.
# For public images, no ENV vars must be set.
- name: Run Trivy vulnerability scanner
if: always()
uses: aquasecurity/trivy-action@7c2007bcb556501da015201bcba5aa14069b74e2 # v0.23.0
with:
# Path to Docker image
image-ref: "${{ env.IMAGE_NAMESPACE }}/ssi-credential-reissuance-app:latest"
format: "sarif"
output: "trivy-results6.sarif"
vuln-type: "os,library"

- name: Upload Trivy scan results to GitHub Security tab
if: always()
uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
with:
sarif_file: "trivy-results6.sarif"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ See Docker notice files for more information:
- [credential-issuer-service](./docker//notice-credential-issuer-service.md)
- [credential-issuer-processes-worker](./docker/notice-credential-issuer-processes-worker.md)
- [credential-expiry-app](./docker/notice-credential-expiry-app.md)
- [credential-reissuance-app](./docker/notice-credential-reissuance-app.md)
- [credential-issuer-migrations](./docker/notice-credential-issuer-migrations.md)

## Contributing
Expand Down
8 changes: 8 additions & 0 deletions charts/ssi-credential-issuer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ dependencies:
| credentialExpiry.logging.default | string | `"Information"` | |
| credentialExpiry.expiry.expiredVcsToDeleteInMonth | int | `12` | |
| credentialExpiry.expiry.inactiveVcsToDeleteInWeeks | int | `12` | |
| credentialReissuance.name | string | `"reissuance"` | |
| credentialReissuance.image.name | string | `"docker.io/tractusx/ssi-credential-reissuance-app"` | |
| credentialReissuance.image.tag | string | `""` | |
| credentialReissuance.imagePullPolicy | string | `"IfNotPresent"` | |
| credentialReissuance.resources | object | `{"limits":{"cpu":"45m","memory":"105M"},"requests":{"cpu":"15m","memory":"105M"}}` | We recommend to review the default resource limits as this should a conscious choice. |
| credentialReissuance.processIdentity.identityId | string | `"23db9ff3-20c7-476c-ba70-6bdfe5c97104"` | |
| credentialReissuance.logging.default | string | `"Information"` | |
| credentialReissuance.expiry.expiredVcsToReissueInDays | int | `1` | |
| existingSecret | string | `""` | Secret containing the client-secrets for the connection to portal and wallet as well as encryptionKeys for issuer.credential and processesworker.wallet |
| dotnetEnvironment | string | `"Production"` | |
| dbConnection.schema | string | `"issuer"` | |
Expand Down
78 changes: 78 additions & 0 deletions charts/ssi-credential-issuer/templates/cronjob-reissuance-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
###############################################################
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "issuer.fullname" . }}-{{ .Values.credentialReissuance.name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "issuer.labels" . | nindent 4 }}
spec:
schedule: "0 0 * * *"
concurrencyPolicy: Forbid
jobTemplate:
metadata:
name: {{ include "issuer.fullname" . }}-{{ .Values.credentialReissuance.name }}
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: {{ include "issuer.fullname" . }}-{{ .Values.credentialReissuance.name }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
image: "{{ .Values.credentialReissuance.image.name }}:{{ .Values.credentialReissuance.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: "{{ .Values.credentialReissuance.imagePullPolicy }}"
env:
- name: DOTNET_ENVIRONMENT
value: "{{ .Values.dotnetEnvironment }}"
{{- if .Values.postgresql.enabled }}
- name: "ISSUER_PASSWORD"
valueFrom:
secretKeyRef:
name: "{{ template "issuer.postgresSecretName" . }}"
key: "password"
- name: "CONNECTIONSTRINGS__ISSUERDB"
value: "Server={{ template "issuer.postgresql.primary.fullname" . }};Database={{ .Values.postgresql.auth.database }};Port={{ .Values.postgresql.auth.port }};User Id={{ .Values.postgresql.auth.username }};Password=$(ISSUER_PASSWORD);Ssl Mode={{ .Values.dbConnection.sslMode }};"
{{- end }}
{{- if not .Values.postgresql.enabled }}
- name: "ISSUER_PASSWORD"
valueFrom:
secretKeyRef:
name: "{{ .Values.externalDatabase.secret }}"
key: "password"
- name: "CONNECTIONSTRINGS__ISSUERDB"
value: "Server={{ .Values.externalDatabase.host }};Database={{ .Values.externalDatabase.database }};Port={{ .Values.externalDatabase.port }};User Id={{ .Values.externalDatabase.username }};Password=$(ISSUER_PASSWORD);Ssl Mode={{ .Values.dbConnection.sslMode }};"
{{- end }}
- name: "REISSUANCE__EXPIREDVCSTOREISSUEINDAYS"
value: "{{ .Values.credentialReissuance.expiry.expiredVcsToReissueInDays }}"
- name: "REISSUANCE__ISSUERBPN"
value: "{{ .Values.service.credential.issuerBpn }}"
ports:
- name: http
containerPort: {{ .Values.portContainer }}
protocol: TCP
resources:
{{- toYaml .Values.credentialReissuance.resources | nindent 14 }}
21 changes: 21 additions & 0 deletions charts/ssi-credential-issuer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ credentialExpiry:
expiredVcsToDeleteInMonth: 12
inactiveVcsToDeleteInWeeks: 12

credentialReissuance:
name: "reissuance"
image:
name: "docker.io/tractusx/ssi-credential-reissuance-app"
tag: ""
imagePullPolicy: "IfNotPresent"
# -- We recommend to review the default resource limits as this should a conscious choice.
resources:
requests:
cpu: 15m
memory: 105M
limits:
cpu: 45m
memory: 105M
processIdentity:
identityId: 23db9ff3-20c7-476c-ba70-6bdfe5c97104
logging:
default: "Information"
expiry:
expiredVcsToReissueInDays: 1

# -- Secret containing the client-secrets for the connection to portal and wallet
# as well as encryptionKeys for issuer.credential and processesworker.wallet
existingSecret: ""
Expand Down
35 changes: 35 additions & 0 deletions docker/Dockerfile-credential-reissuance-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
###############################################################
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish
ARG TARGETARCH
WORKDIR /
COPY LICENSE NOTICE.md DEPENDENCIES /
COPY src/ src/
RUN dotnet restore "src/credentials/SsiCredentialIssuer.Reissuance.App/SsiCredentialIssuer.Reissuance.App.csproj"
WORKDIR /src/credentials/SsiCredentialIssuer.Reissuance.App
RUN dotnet publish "SsiCredentialIssuer.Reissuance.App.csproj" -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine
ENV COMPlus_EnableDiagnostics=0
WORKDIR /app
COPY --from=publish /app/publish .
RUN chown -R 1000:3000 /app
USER 1000:3000
ENTRYPOINT ["dotnet", "Org.Eclipse.TractusX.SsiCredentialIssuer.Reissuance.App.dll"]
Loading