-
Notifications
You must be signed in to change notification settings - Fork 106
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: Add Identity service #218
Conversation
…magra as Git submodules Signed-off-by: Yash Mittal <[email protected]>
Signed-off-by: Yash Mittal <[email protected]>
Signed-off-by: Yash Mittal <[email protected]>
jwksRequestsPerMinute: 5, | ||
jwksUri: process.env.JWKS_URI, | ||
}), | ||
algorithms: ['RS256'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let this be configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added as an env var
|
||
async generateDID(doc: GenerateDidDTO): Promise<DIDDocument> { | ||
// Create private/public key pair | ||
const authnKeys = await ION.generateKeyPair('Ed25519'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it configurable.
RSA or ED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added as a env var
console.log(authnKeys); | ||
|
||
// Create a UUID for the DID using uuidv4 | ||
const didUri = 'did:ulp:' + uuid(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ULP keyword and make it configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done refer: 6af1cd1
didDoc: JSON.stringify(document), | ||
}, | ||
}); | ||
this.vault.writePvtKey(authnKeys.privateJwk, didUri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also error handlings are missing,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
// const did = new ION.DID({ | ||
// content: content, | ||
// }); | ||
|
||
// const anchorRequestBody = await did.generateRequest(); | ||
// const didUri: string = await did.getURI('short'); | ||
// const anchorRequest = new ION.AnchorRequest(anchorRequestBody); | ||
// const anchorResponse = await anchorRequest.submit(); | ||
// if (anchorResponse) { | ||
// await this.prisma.identity.create({ | ||
// data: { | ||
// id: didUri, | ||
// didDoc: anchorResponse as DIDDocument, | ||
// privateKey: authnKeys.privateJwk, | ||
// }, | ||
// }); | ||
|
||
// return anchorResponse; | ||
// } else { | ||
// throw new Error('err'); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented codes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@@ -0,0 +1,45 @@ | |||
node() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be present within the repo. I think this can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the jenkins file we created to deploy the service to the internal samagra devops pipelines. Do we need to remove this entirely so can we keep this as alternate deployment strategy ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the file has been resolved as per discussion during the standup
"description": "", | ||
"author": "", | ||
"private": true, | ||
"license": "UNLICENSED", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add appropriate license.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added MIT License
} | ||
} | ||
|
||
// @Patch('/update/:id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete if not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
authentication: ['auth-key'], | ||
}; | ||
// print the document using pretty json | ||
console.log(JSON.stringify(document, null, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
} | ||
} | ||
|
||
// async resolveDID(id: string): Promise<DIDDocument> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments should be removed everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
private vault = new Vault( { | ||
https: false, | ||
baseUrl: `${process.env.VAULT_ADDR}/v1`, | ||
rootPath: `${process.env.VAULT_ADDR}/v1/kv`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be made configurable throughout. We can have vault address and root path as two env variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added as env vars
@@ -0,0 +1,15 @@ | |||
import { ApiProperty } from "@nestjs/swagger"; | |||
|
|||
export class RegisterUserDTO { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have OTP and password within a DTO. These should be handled by the authentication provider. Only consent should be transmitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a mock aadhar service, this code has been removed from the service
feat: Add targets for identity-service
} | ||
|
||
async resolveDID(id: string): Promise<any> { | ||
console.log('did in resolveDID: ', id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use nest js logger, and leverage different log levels
|
|
@techsavvyash can you share the API spec for this service? |
@@ -0,0 +1,36 @@ | |||
import { BadRequestException, Body, Controller, Get, Param, Post } from '@nestjs/common'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these APIS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, these were written to enable a mock aadhar based login flow to create DIDs, and have been removed
@ApiInternalServerErrorResponse({ description: 'Internal Server Error' }) | ||
@Post('/sign') | ||
sign(@Body() body: SignJsonDTO) { | ||
console.log('tjis') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unwanted logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@ApiOperation({ summary: 'Verify a signed VC' }) | ||
@Post('/verify') | ||
verify(@Body() body: VerifyJsonDTO) { | ||
return this.VcService.sign(body.DID, body.payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it call sign
function for verify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has been resolved
Update setup_vault.sh
Update setup_vault.sh
fix: Fix tests, docker-compose-test, and setup_vault.sh
feat: add health checks for DB container
#10) * feat: add health checks to vault and use test network for test containers * feat: health checks for identity service
@techsavvyash Please add a readme with the list of supported environment variables as well. This way it will be easy to document at a later point. |
@techsavvyash can you also share the coverage metrics? |
have added a |
|
Description
This PR contains the code for the identity service.