From 594ce92068ae4775d7a1493fd1922dab0fd0abf2 Mon Sep 17 00:00:00 2001 From: Pratap2018 Date: Wed, 6 Mar 2024 12:32:31 +0530 Subject: [PATCH] update --- .github/workflows/pipeline.yaml | 9 ++-- exp/deployment.yaml | 95 +++++++++++++++++++++++++++++++++ src/models/userModel.ts | 3 ++ src/routes/auth.ts | 3 +- src/routes/edvRoutes.ts | 16 +++++- 5 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 exp/deployment.yaml diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index 281c392..fadf7db 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -2,10 +2,11 @@ name: AuthServer Build and deploy Pipeline on: push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" - - "v[0-9]+.[0-9]+.[0-9]-rc.[0-9]+" - + # tags: + # - "v[0-9]+.[0-9]+.[0-9]+" + # - "v[0-9]+.[0-9]+.[0-9]-rc.[0-9]+" + branches: + - "devops" jobs: Build-Pipeline: runs-on: ubuntu-latest diff --git a/exp/deployment.yaml b/exp/deployment.yaml new file mode 100644 index 0000000..75fed25 --- /dev/null +++ b/exp/deployment.yaml @@ -0,0 +1,95 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: auth-server + namespace: hypermine-development +spec: + replicas: 1 + selector: + matchLabels: + app: auth-server + template: + metadata: + labels: + app: auth-server + spec: + containers: + - name: auth-server + image: pratapmridha/auth-server + imagePullPolicy: Always + volumeMounts: + - mountPath: "/data" + name: auth-server-hypersign-json + readOnly: false + resources: + limits: + memory: "1Gi" + cpu: "500m" + ports: + - containerPort: 8001 + env: + - name: AUTH0TENANT + value: "https://fidato.us.auth0.com/" + - name: DATA_DIR + value: data + - name: DB_INMEM + value: "false" + - name: DB_URL + value: "mongodb+srv://pratap:Pratap%402018@cluster0.xzgmnbz.mongodb.net/authserver?retryWrites=true&w=majority" + - name: EDV_BASE_URL + value: "https://edv.hypersign.id" + - name: EDV_CONFIG_DIR + value: ".authserver-edv-config" + - name: EDV_DID_FILE_PATH + value: ".authserver-edv-config/edv-did.json" + - name: EDV_ID + value: "urn:uuid:2b9d8b0a-2b9d-4b0a-8b0a-2b9d8b0a2b9:wallet-prajna-edvs" + - name: EDV_KEY_FILE_PATH + value: ".authserver-edv-config/edv-key.json" + - name: HIDNODE_REST_URL + value: "https://api.prajna.hypersign.id/" + - name: HIDNODE_RPC_URL + value: "https://rpc.prajna.hypersign.id/" + - name: HID_WALLET_MNEMONIC + value: "sword comic lunar chalk runway evolve brand jungle glare opera submit promote defense unveil require yellow night hidden pupil setup fringe avocado ginger champion" + - name: HOST + value: "127.0.0.1" + - name: LOG_LEVEL + value: debug + - name: MAXIMUM_DELAY + value: "60000" + - name: MAX_BATCH_SIZE + value: "500" + - name: MINIMUM_DELAY + value: "5000" + - name: NODE_ENV + value: production + - name: PORT + value: "8001" + - name: REDIS_HOST + value: redis-stack-service.hypermine-development.svc.cluster.local + - name: REDIS_PORT + value: "6379" + - name: SERVICE_END_POINT + value: "https://authserver.hypersign.id/" + - name: WHITELISTED_CORS + value: '[ "https://dashboard.hypermine.in","wallet-stage.hypersign.id" , "https://whitelist.hypermine.in", "https://wallet.hypermine.in", "https://ssi.hypermine.in", "http://localhost:4999", "https://hswallet-stage.netlify.app", "https://hyperfyre.netlify.app", "https://wallet-stage.hypersign.id/", "https://hswallet-stage.netlify.app","https://wallet-prajna.hypersign.id"]' + volumes: + - name: auth-server-hypersign-json + secret: + secretName: auth-server-hypersign-json +--- +apiVersion: v1 +kind: Service +metadata: + name: auth-server-service + namespace: hypermine-development + +spec: + type: NodePort + selector: + app: auth-server + ports: + - port: 8001 + targetPort: 8001 + protocol: TCP diff --git a/src/models/userModel.ts b/src/models/userModel.ts index 19a6ad7..9db7f8c 100644 --- a/src/models/userModel.ts +++ b/src/models/userModel.ts @@ -5,6 +5,7 @@ export interface IUserModel extends Document { userId: string; sequence: number; docId: string; + nameSpace:string } @@ -12,6 +13,8 @@ const user = new Schema({ userId: { type: String, required: true , unique: true }, sequence: { type: Number, required: true }, docId: { type: String, required: true }, + nameSpace: { type: String, required: true }, + }) diff --git a/src/routes/auth.ts b/src/routes/auth.ts index e07fbb0..f08d0eb 100644 --- a/src/routes/auth.ts +++ b/src/routes/auth.ts @@ -52,11 +52,12 @@ function addExpirationDateMiddleware(req, res, next) { export = (hypersign: IHypersignAuth, edvClient) => { const router = Router(); - async function getUserDocIdIfUserExists(userId) { + async function getUserDocIdIfUserExists(userId, nameSpace = "default") { try { console.log("authRoutes:: getUserDocIdIfUserExists(): starts"); const equals: { [key: string]: string } = { ["content.userId"]: userId, + ["content.nameSpace"]: nameSpace, }; console.log( "authRoutes:: getUserDocIdIfUserExists(): Before quering edvClient for userID " + diff --git a/src/routes/edvRoutes.ts b/src/routes/edvRoutes.ts index 2c58852..b930870 100644 --- a/src/routes/edvRoutes.ts +++ b/src/routes/edvRoutes.ts @@ -9,14 +9,20 @@ export = (hypersign, edvClient) => { userId: userData.userId, sequence: 0, docId: docId, + nameSpace: userData.nameSpace ? "default" : userData.nameSpace, } as IUserModel; } - async function getUserDocIdIfUserExists(userId, getRawData: boolean = false) { + async function getUserDocIdIfUserExists( + userId, + nameSpace, + getRawData: boolean = false + ) { try { let data = null; const equals: { [key: string]: string } = { ["content.userId"]: userId, + ["content.nameSpace"]: nameSpace, }; const userDataInEdv: Array = await edvClient.query(equals); if (!Array.isArray(userDataInEdv)) { @@ -76,11 +82,17 @@ export = (hypersign, edvClient) => { ); const equals: { [key: string]: string } = { ["content.userId"]: userData.userId, + ["content.nameSpace"]: userData.nameSpace + ? "default" + : userData.nameSpace, }; const userDataInEdv: Array = await edvClient.query(equals); console.log("User data in edv " + JSON.stringify(userDataInEdv)); - const userDocInEdv = await getUserDocIdIfUserExists(userData.userId); + const userDocInEdv = await getUserDocIdIfUserExists( + userData.userId, + userData.nameSpace + ); const { userDocId } = userDocInEdv; console.log( "edvRoutest:: sync(): After checking if user exists with doc id " +