From 0880aaf0cdb0f9929f9f3a8407f444badb2af852 Mon Sep 17 00:00:00 2001 From: Nithin Shekar Kuruba Date: Wed, 1 Nov 2023 18:09:55 -0700 Subject: [PATCH] feat: update verifiable to digital credentials --- ...{remove-vc-users.js => remove-dc-users.js} | 22 +++++++++---------- helm/kc-cron-job/Makefile | 2 +- helm/kc-cron-job/README.md | 2 +- ...c-users.yaml => cron-remove-dc-users.yaml} | 10 ++++----- 4 files changed, 18 insertions(+), 18 deletions(-) rename docker/kc-cron-job/{remove-vc-users.js => remove-dc-users.js} (80%) rename helm/kc-cron-job/templates/{cron-remove-vc-users.yaml => cron-remove-dc-users.yaml} (96%) diff --git a/docker/kc-cron-job/remove-vc-users.js b/docker/kc-cron-job/remove-dc-users.js similarity index 80% rename from docker/kc-cron-job/remove-vc-users.js rename to docker/kc-cron-job/remove-dc-users.js index 51887de3..f2722310 100644 --- a/docker/kc-cron-job/remove-vc-users.js +++ b/docker/kc-cron-job/remove-dc-users.js @@ -3,15 +3,15 @@ const async = require('async'); const STANDARD_REALM = 'standard'; -const VC_REALM = 'verifiablecredential'; +const DC_REALM = 'digitalcredential'; async function removeVcUsers(runnerName, pgClient, env = 'dev', callback) { try { let deletedUserCount = 0; const adminClient = await getAdminClient(env); - const idpSuffix = '@verifiablecredential'; + const idpSuffix = '@digitalcredential'; await pgClient.connect(); - const text = 'INSERT INTO kc_deleted_vc_users (environment, username, realm_id, attributes) VALUES($1, $2, $3, $4)'; + const text = 'INSERT INTO kc_deleted_dc_users (environment, username, realm_id, attributes) VALUES($1, $2, $3, $4)'; const max = 500; let first = 0; let total = 0; @@ -32,14 +32,14 @@ async function removeVcUsers(runnerName, pgClient, env = 'dev', callback) { await adminClient.users.del({ realm: STANDARD_REALM, id }); const parentRealmUsers = await adminClient.users.find({ - realm: VC_REALM, + realm: DC_REALM, username: username.split('@')[0], max: 1 }); if (parentRealmUsers.length > 0) { - // delete user from verifiable credential realm - await adminClient.users.del({ realm: VC_REALM, id: parentRealmUsers[0]?.id }); + // delete user from digital credential realm + await adminClient.users.del({ realm: DC_REALM, id: parentRealmUsers[0]?.id }); } const values = [env, username, STANDARD_REALM, users[x].attributes || {}]; @@ -83,22 +83,22 @@ async function main() { if (err) { console.error(err.message); await sendRcNotification( - 'vc-remove-users', - `**[${process.env.NAMESPACE}] Failed to remove vc users** \n\n` + err.message, + 'dc-remove-users', + `**[${process.env.NAMESPACE}] Failed to remove digital credential users** \n\n` + err.message, true ); } else { const a = results.map((res) => JSON.stringify(res)); await sendRcNotification( - 'vc-remove-users', - `**[${process.env.NAMESPACE}] Successfully removed vc users** \n\n` + a.join('\n\n'), + 'dc-remove-users', + `**[${process.env.NAMESPACE}] Successfully removed digital credential users** \n\n` + a.join('\n\n'), false ); } } ); - await deleteLegacyData('kc_deleted_vc_users', process.env.VC_USERS_RETENTION_DAYS || 60); + await deleteLegacyData('kc_deleted_dc_users', process.env.DC_USERS_RETENTION_DAYS || 60); } main(); diff --git a/helm/kc-cron-job/Makefile b/helm/kc-cron-job/Makefile index bff10b3c..d3bf096f 100644 --- a/helm/kc-cron-job/Makefile +++ b/helm/kc-cron-job/Makefile @@ -56,7 +56,7 @@ kc-cron-job-secret: --from-literal=bceid-service-id-test=${BCEID_SERVICE_ID_TEST} \ --from-literal=prod-kc-client-id=${PROD_KEYCLOAK_CLIENT_ID} \ --from-literal=rc-webhook=${RC_WEBHOOK} \ - --from-literal=vc-users-retention-days=${VC_USERS_RETENTION_DAYS} \ + --from-literal=dc-users-retention-days=${DC_USERS_RETENTION_DAYS} \ --from-literal=inactive-idir-users-retention-days=${INACTIVE_IDIR_USERS_RETENTION_DAYS} \ --from-literal=dev-kc-url=${DEV_KEYCLOAK_URL} \ --from-literal=test-kc-url=${TEST_KEYCLOAK_URL} \ diff --git a/helm/kc-cron-job/README.md b/helm/kc-cron-job/README.md index e9fdae14..6bc79e31 100644 --- a/helm/kc-cron-job/README.md +++ b/helm/kc-cron-job/README.md @@ -36,7 +36,7 @@ export PGDATABASE= export CSS_API_URL=http://localhost:8080/app export CSS_API_AUTH_SECRET= export RC_WEBHOOK= -export VC_USERS_RETENTION_DAYS= +export DC_USERS_RETENTION_DAYS= export INACTIVE_IDIR_USERS_RETENTION_DAYS= # update and run to create the secret diff --git a/helm/kc-cron-job/templates/cron-remove-vc-users.yaml b/helm/kc-cron-job/templates/cron-remove-dc-users.yaml similarity index 96% rename from helm/kc-cron-job/templates/cron-remove-vc-users.yaml rename to helm/kc-cron-job/templates/cron-remove-dc-users.yaml index 54a522f7..e4449be6 100644 --- a/helm/kc-cron-job/templates/cron-remove-vc-users.yaml +++ b/helm/kc-cron-job/templates/cron-remove-dc-users.yaml @@ -2,7 +2,7 @@ apiVersion: batch/v1 kind: CronJob metadata: - name: {{ include "..fullname" . }}-rm-vc-users + name: {{ include "..fullname" . }}-rm-dc-users namespace: {{ .Values.namespace.rmVcUsers }} labels: app.kubernetes.io/name: {{ include "..name" . }} @@ -31,7 +31,7 @@ spec: set -euo pipefail; echo "select 'create database $PGDATABASE' where NOT exists (select from pg_database where datname = '$PGDATABASE')\gexec" | psql -d postgres psql -d $PGDATABASE -qtA --set ON_ERROR_STOP=1 <