-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from techsavvyash/credential
Feat: Credential Service
- Loading branch information
Showing
61 changed files
with
10,018 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
**/node_modules | ||
**/build | ||
**/build | ||
**/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
DATABASE_URL="" | ||
SCHEMA_BASE_URL="" | ||
|
||
# Auth related vars | ||
JWKS_URI="" | ||
ENABLE_AUTH=false | ||
|
||
# Core Service Vars | ||
IDENTITY_BASE_URL= # URL of the identity service to facilitate DID creation | ||
|
||
# Service VARS | ||
SCHEMA_BASE_URL= | ||
|
||
CREDENTIAL_SERVICE_BASE_URL="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.env | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM node:16 AS install | ||
RUN apt-get update \ | ||
&& apt-get install -y wkhtmltopdf | ||
WORKDIR /app | ||
COPY package.json yarn.lock ./ | ||
RUN yarn | ||
|
||
FROM node:16 as build | ||
WORKDIR /app | ||
COPY prisma ./prisma/ | ||
COPY --from=install /app/node_modules ./node_modules | ||
RUN npx prisma generate | ||
COPY . . | ||
RUN yarn build | ||
|
||
FROM node:16 | ||
RUN apt-get update \ | ||
&& apt-get install -y wkhtmltopdf=0.12.5-1 | ||
|
||
WORKDIR /app | ||
COPY --from=build /app/dist ./dist | ||
COPY --from=build /app/package*.json ./ | ||
COPY --from=build /app/prisma ./prisma | ||
COPY --from=build /app/node_modules ./node_modules | ||
EXPOSE 3000 | ||
CMD [ "npm", "run", "start:migrate:prod" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM node:16 AS install | ||
WORKDIR /app | ||
COPY package.json yarn.lock ./ | ||
RUN yarn | ||
|
||
FROM node:16 as build | ||
RUN apt-get update \ | ||
&& apt-get install -y wkhtmltopdf=0.12.5-1 | ||
WORKDIR /app | ||
COPY prisma ./prisma/ | ||
COPY --from=install /app/node_modules ./node_modules | ||
RUN npx prisma generate | ||
COPY . . | ||
EXPOSE 3333 | ||
CMD [ "yarn", "test:migrate"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
IMAGE:=dockerhub/sunbird-rc-credentials-service | ||
|
||
.PHONY: docker publish test | ||
|
||
docker: | ||
@docker build -t $(IMAGE) . | ||
publish: | ||
@docker push $(IMAGE) | ||
test: | ||
# Resetting vault of identity-service before running the tests | ||
make -C ../identity-service stop | ||
make -C ../credential-schema stop | ||
make -C ../identity-service vault-reset | ||
# Creating an external docker network to connnect services in different compose | ||
@docker network create rcw-test || echo "" | ||
# Starting dependent services | ||
make -C ../identity-service compose-init | ||
make -C ../credential-schema compose-init | ||
@docker-compose -f docker-compose-test.yml down | ||
@docker-compose -f docker-compose-test.yml up --build --abort-on-container-exit | ||
|
||
# Stopping all dependent services | ||
make -C ../identity-service stop | ||
make -C ../identity-service vault-reset | ||
make -C ../credential-schema stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Credential Microservice | ||
|
||
## Description | ||
|
||
[Nest](https://github.com/nestjs/nest) based CRUD APIs to, claim, sign and generate shareable verifiable credentials. This repository is intended to be used with the [Unified Learner's Passbook](http://github.com/Unified-Learners-Passbook) project in the state of Uttar Pradesh, India. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ npm install | ||
``` | ||
OR | ||
```bash | ||
$ npx yarn | ||
``` | ||
|
||
## Running the app | ||
|
||
```bash | ||
# development | ||
$ npm run start | ||
|
||
# watch mode | ||
$ npm run start:dev | ||
|
||
# production mode | ||
$ npm run start:prod | ||
``` | ||
|
||
OR | ||
|
||
```bash | ||
# development | ||
$ npx yarn run start | ||
|
||
# watch mode | ||
$ npx yarn run start:dev | ||
|
||
# production mode | ||
$ npx yarn run start:prod | ||
``` | ||
|
||
|
||
## Test | ||
|
||
```bash | ||
# unit tests | ||
$ npm run test | ||
|
||
# e2e tests | ||
$ npm run test:e2e | ||
|
||
# test coverage | ||
$ npm run test:cov | ||
``` | ||
|
||
OR | ||
|
||
```bash | ||
# unit tests | ||
$ npx yarn run test | ||
|
||
# e2e tests | ||
$ npx yarn run test:e2e | ||
|
||
# test coverage | ||
$ npx yarn run test:cov | ||
``` | ||
|
||
OR | ||
|
||
``` | ||
# Run tests in container from services/credential-service folder | ||
$ make test | ||
# Run tests in container from base folder | ||
$ make -C services/credentials-service test | ||
``` | ||
## Stay in touch | ||
|
||
- Author - [Yash Mittal](https://github.com/techsavvyash) and [Radhay Anand](https://github.com/radhay-1199) | ||
|
||
## License | ||
|
||
Nest is [MIT licensed](LICENSE). | ||
|
||
## Links | ||
|
||
- [W3C VC API](https://w3c-ccg.github.io/vc-api/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
wrk.method = "POST" | ||
wrk.body = "{\n \"credential\": {\n \"@context\": [\n \"https://www.w3.org/2018/credentials/v1\",\n \"https://www.w3.org/2018/credentials/examples/v1\"\n ],\n \"type\": [\n \"VerifiableCredential\",\n \"UniversityDegreeCredential\"\n ],\n \"issuer\": \"did:ulp:2010a34d-4292-4c1c-83ae-e7559a90931c\",\n \"issuanceDate\": \"2023-02-06T11:56:27.259Z\",\n \"expirationDate\": \"2023-02-08T11:56:27.259Z\",\n \"credentialSubject\": {\n \"id\": \"did:ulp:977ba77a-a549-4f3f-8d8c-eef01fe616a2\",\n \"grade\": \"6.23\",\n \"programme\": \"BCA\",\n \"certifyingInstitute\": \"IIIT Sonepat\",\n \"evaluatingInstitute\": \"NIT Kurukshetra\"\n },\n \"options\": {\n \"created\": \"2020-04-02T18:48:36Z\",\n \"credentialStatus\": {\n \"type\": \"RevocationList2020Status\"\n }\n }\n },\n \"credentialSchema\": {\n \"id\": \"did:ulpschema:c9cc0f03-4f94-4f44-9bcd-b24a86596fa2\",\n \"type\": \"https://w3c-ccg.github.io/vc-json-schemas/\",\n \"version\": \"1.0\",\n \"name\": \"Proof of Academic Evaluation Credential\",\n \"author\": \"did:example:c276e12ec21ebfeb1f712ebc6f1\",\n \"authored\": \"2022-12-19T09:22:23.064Z\",\n \"schema\": {\n \"$id\": \"Proof-of-Academic-Evaluation-Credential-1.0\",\n \"type\": \"object\",\n \"$schema\": \"https://json-schema.org/draft/2019-09/schema\",\n \"required\": [\n \"grade\",\n \"programme\",\n \"certifyingInstitute\",\n \"evaluatingInstitute\"\n ],\n \"properties\": {\n \"grade\": {\n \"type\": \"string\",\n \"description\": \"Grade (%age, GPA, etc.) secured by the holder.\"\n },\n \"programme\": {\n \"type\": \"string\",\n \"description\": \"Name of the programme pursed by the holder.\"\n },\n \"certifyingInstitute\": {\n \"type\": \"string\",\n \"description\": \"Name of the instute which certified the said grade in the said skill\"\n },\n \"evaluatingInstitute\": {\n \"type\": \"string\",\n \"description\": \"Name of the institute which ran the programme and evaluated the holder.\"\n }\n },\n \"description\": \"The holder has secured the <PERCENTAGE/GRADE> in <PROGRAMME> from <ABC_Institute>.\",\n \"additionalProperties\": false\n }\n }\n}" | ||
wrk.headers["Content-Type"] = "application/json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
node() { | ||
withCredentials([string(credentialsId: 'docker_server', variable: 'docker_server')]) { | ||
properties([ | ||
parameters([ | ||
string(name: 'docker_repo', defaultValue: 'samagragovernance/credential-ms', description: 'Docker Image Name'), | ||
string(name: 'docker_server', defaultValue: "$docker_server", description: 'Docker Registry URL'), | ||
]) | ||
]) | ||
} | ||
stage('Checkout') { | ||
cleanWs() | ||
checkout scm | ||
env.commit_id = env.BRANCH_NAME | ||
echo "${env.commit_id}" | ||
} | ||
|
||
stage('docker-build') { | ||
sh ''' | ||
docker build -f Dockerfile -t $docker_server/$docker_repo:$commit_id . | ||
''' | ||
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'master') { | ||
sh ''' | ||
docker build -f Dockerfile -t $docker_server/$docker_repo:latest . | ||
''' | ||
} | ||
} | ||
|
||
stage('docker-push') { | ||
sh ''' | ||
docker push $docker_server/$docker_repo:$commit_id | ||
''' | ||
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'master') { | ||
sh ''' | ||
docker push $docker_server/$docker_repo:latest | ||
''' | ||
} | ||
} | ||
|
||
stage('Start deploy job with latest tag') { | ||
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'master') { | ||
build job: 'ULP/deploy-staging/credential-ms/', parameters: [string(name: 'tag', value: 'latest')] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: '3' | ||
|
||
services: | ||
db-test: | ||
image: postgres:12 | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
healthcheck: | ||
test: [ "CMD-SHELL", "pg_isready -U postgres" ] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
credentials-service-test: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test | ||
depends_on: | ||
db-test: | ||
condition: service_healthy | ||
environment: | ||
DATABASE_URL: postgres://postgres:postgres@db-test:5432/postgres | ||
IDENTITY_BASE_URL: "http://identity-service:3332" | ||
SCHEMA_BASE_URL: "http://credential-schema:3333" | ||
ENABLE_AUTH: "false" | ||
JWKS_URI: "" | ||
SIGNING_ALGORITHM: "RS256" | ||
networks: | ||
rcw-test: | ||
default: | ||
|
||
networks: | ||
rcw-test: | ||
external: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
version: '3' | ||
|
||
services: | ||
db: | ||
image: postgres:12 | ||
environment: | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_USER=postgres | ||
volumes: | ||
- data:/var/lib/postgresql/data | ||
healthcheck: | ||
test: [ "CMD-SHELL", "pg_isready -U postgres" ] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
credentials-service: | ||
image: cred | ||
build: . | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
ports: | ||
- '3000:3000' | ||
environment: | ||
DATABASE_URL: postgres://postgres:postgres@db:5432/postgres | ||
IDENTITY_BASE_URL: | ||
SCHEMA_BASE_URL: | ||
ENABLE_AUTH: "false" | ||
JWKS_URI: "" | ||
SIGNING_ALGORITHM: "RS256" | ||
healthcheck: | ||
test: | ||
[ "CMD-SHELL", "curl -f http://localhost:3000/health || exit 1" ] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
networks: | ||
rcw-test: | ||
default: | ||
|
||
networks: | ||
rcw-test: | ||
external: true | ||
|
||
volumes: | ||
data: |
Oops, something went wrong.