Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratap2018 committed Mar 6, 2024
1 parent 86c409f commit 594ce92
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 7 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
95 changes: 95 additions & 0 deletions exp/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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%[email protected]/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
3 changes: 3 additions & 0 deletions src/models/userModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ export interface IUserModel extends Document {
userId: string;
sequence: number;
docId: string;
nameSpace:string

}

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 },

})


Expand Down
3 changes: 2 additions & 1 deletion src/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +
Expand Down
16 changes: 14 additions & 2 deletions src/routes/edvRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> = await edvClient.query(equals);
if (!Array.isArray(userDataInEdv)) {
Expand Down Expand Up @@ -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<any> = 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 " +
Expand Down

0 comments on commit 594ce92

Please sign in to comment.