Pre-requisites:
- Java 21, Postgres DB installed & configured
- Git Bash for Windows users
- Clone the repo, usually the active development happens on the
developbranch but one can check out a tagged version as well. - Run the DB init scripts present in
db_scripts/inji_certify, running./deploy.sh deploy.propertiesis a good way to init the DB. - Decide on the issuance mode of Certify. Some plugins enable Certify to operate as a Proxy and others enable it to work as an Issuer, configure
mosip.certify.plugin-modeappropriately asDataProviderorVCIssuance.- [Recommended] Set it to
DataProviderif you want a quickest possible working setup, and configuremosip.certify.data-provider-plugin.did-urlappropriately. - If you have another Issuance module such as Sunbird, MOSIP Stack, you may want to set it up in
VCIssuancemode.
- [Recommended] Set it to
- Decide on the VCI plugin for use locally and configure it, while running locally from an IDE such as Eclipse or IntelliJ one needs to add configuration to the
application-local.propertiesand add the VCI plugin dependency JAR to the certify-service project which implements one ofDataProviderPluginorVCIssuancePlugininterfaces. - Get a compatible eSignet setup running configured with the appropriate Authenticator plugin implementation matching the VCI plugin.
- Configure
mosip.certify.authorization.urlto point to your Authorization service hostname, this could be a working eSignet instance or another AuthZ provider configured with an Authenticator plugin implementation, essentially enabling the VC Issuing plugin to do the work. - Configure
mosip.certify.domain.url,mosip.certify.identifier,mosip.certify.authn.issuer-uri,mosip.certify.authn.jwk-set-uri,mosip.certify.authn.allowed-audiencesappropriately as per the Authorization service and Certify URI. - Configure your Verifiable Credential types, scopes and other well-known attributes via the
/credential-configurationsAPI (stored in thecredential_configtable). Refer to Credential_Issuer_Configuration.md for details. - Appropriately configure the
mosip.certify.authn.allowed-audiencesto allowed audiences such that it matches with the AuthZ token when the Credential issue request is made to Certify.
- Configure
- (required if Mobile driving license configured) Onboard issuer key and certificate data into property
mosip.certify.mock.mdoc.issuer-key-certusing the creation script. - Perform Authentication & VC Issuance to see if the Certify & AuthZ stack is working apprpriately. Look out for the Postman collections referred to in the main README.md of this project.
- Use the Inji Certify Pre Auth Code collection located at
docs/postman_collections/pre_authorization_code_flow/inji-certify-pre-auth-code.postman_collection.jsonto test the "Credential Offer with Pre Authorization Code Flow".
- Use the Inji Certify Pre Auth Code collection located at
This guide outlines how to use an existing certify plugin or build a custom plugin.
These steps prepare your custom plugin JAR file.
Get the source code for the plugins.
git clone https://github.com/inji/digital-credential-pluginsCurrently, certify supports 2 types of plugins in DataProvider mode.
This plugin reads user data from a CSV file.
- Location: MockCSVDataProviderPlugin
# Set Plugin Mode
mosip.certify.plugin-mode=DataProvider
#Set Plugin Class Implementation
mosip.certify.integration.data-provider-plugin=MockCSVDataProviderPlugin
## CSV Plugin specific configurations
# Path to CSV file
# Classpath can be used to load file from resources folder
mosip.certify.mock.data-provider.csv-registry-uri=classpath:farmer_identity_data.csv
# Use the correct URI if the file is hosted.
#mosip.certify.mock.data-provider.csv-registry-uri=https://inji.github.io/inji-config/collab/farmer-identity-data.csv
# Identifier Column in CSV
mosip.certify.mock.data-provider.csv.identifier-column=id
# CSV data columns
mosip.certify.mock.data-provider.csv.data-columns=id,name,age<dependency>
<groupId>io.inji.certify</groupId>
<artifactId>mock-certify-plugin</artifactId>
<!-- Use the latest release from https://github.com/inji/digital-credential-plugins/releases (or the version if the existing plugin is modified) -->
<version>LATEST_RELEASE_VERSION</version>
</dependency>This plugin fetches user data from a PostgreSQL database.
- Location: PostgresDataProviderPlugin
# Set Plugin Mode
mosip.certify.plugin-mode=DataProvider
#Set Plugin Class Implementation
mosip.certify.integration.data-provider-plugin=PostgresDataProviderPlugin
## Postgres Plugin specific configurations
# Define a OpenID scope to DB query map where :id is fetched from the "sub" field of the token.
# sample_vc_ldp is the credential scope
# farmer_data is the table name and farmer_id is the column to be matched with :id
mosip.certify.data-provider-plugin.postgres.scope-query-mapping={\
'sample_vc_ldp': 'select * from farmer_data where farmer_id=:id'\
}<dependency>
<groupId>io.inji.certify</groupId>
<artifactId>postgres-dataprovider-plugin</artifactId>
<!-- Use the latest release from https://github.com/inji/digital-credential-plugins/releases (or the version if the existing plugin is modified) -->
<version>LATEST_RELEASE_VERSION</version>
</dependency>Create a new project or modify an existing project within the cloned repository.
References:
- Implement
DataProviderPluginorVCIssuancePlugininterfaces from Certify Plugin API - Write your custom logic to fetch data and/or issue VCs.
Note: Recommended to use
DataProviderPluginfor most use cases.
Navigate to your project folder inside the digital-credential-plugins repository and run the build command. This generates the snapshot JAR in your local Maven repository.
mvn clean install -Dgpg.skip=true- Add the plugin dependency to
certify-service/pom.xmlas shown above. - Run the application using your IDE from the Certify Service Application
- Use the CredentialConfig endpoints to add a vc type to local certify issuer. Refer to Credential_Issuer_Configuration.md and Mosip Stoplight Documentation for more details.
Note: Refer to Resources folder for sample configuration files for default setup. Use the
/credential-configurationsPOST api endpoint for adding the configuration. - Update the
didUrl,vcTemplate,signatureCryptoSuite,keyManagerAppId,keyManagerRefId,signatureAlgo,formatand other relevant fields in the Credential Configuration appropriately to match your plugin and VC format. - Access the did.json endpoint at
http://localhost:8090/v1/certify/.well-known/did.jsonto get the DID document. This did.json document can be hosted in the following ways:
- Update the
mosip.certify.data-provider-plugin.did-urlto a did url from where did.json can be hosted.mosip.certify.data-provider-plugin.did-url=did:web:someuser.github.io:somerepo:somedirectory - (required for VC verification) Certify will automatically generate the DID document for your use case at this endpoint, please copy the contents of the HTTP response and host it appropriately in the same location.
- A did with the ID
did:web:someuser.github.io:somerepo:somedirectorywill be accessible athttps://someuser.github.io/somerepo/somedirectory/did.json, i.e. if GitHub Pages is used to host the file, the contents should go in https://github.com/someuser/somerepo/blob/gh-pages/somedirectory/did.json assuminggh-pagesis the branch for publishing GitHub Pages as per repository settings. - To verify if everything is working you can try to resolve the DID via public DID resolvers such as Uniresolver.
- A did with the ID
- Update the
didUrlfield of thecredentialConfigto have the same value as the above property to verify the VC.
- Use the Postman collection and environment located at Inji Certify Mock Collection and Inji Certify Mock Environment to test the VC issuance flow.
- Locate the
8. Get CredentialPOST request inside the VCI folder - Send the VC request and the response will be farmer credential json.
- Try verification with Univerifier
To setup presentation requirement during issuance, follow the steps below:
-
Configuration: Use the following properties in
application-local.propertiesto setup presentation requirement during issuance.## Use certify as Auth Server # Use below properties to use certify as authorization server #mosip.certify.authorization.url=http://localhost:8090 #mosip.certify.authn.issuer-uri=${mosip.certify.authorization.url} #mosip.certify.authn.jwk-set-uri=${mosip.certify.authorization.url}${server.servlet.path}/.well-known/jwks.json #mosip.certify.authn.allowed-audiences={ '${mosip.certify.authorization.url}${server.servlet.path}/issuance/credential' } ## Auth Server Configurations mosip.certify.oauth.issuer=${mosip.certify.authorization.url} mosip.certify.oauth.token-endpoint=${mosip.certify.authorization.url}${server.servlet.path}/oauth/token mosip.certify.oauth.jwks-uri=${mosip.certify.authorization.url}${server.servlet.path}/.well-known/jwks.json mosip.certify.oauth.grant-types-supported=authorization_code,urn:ietf:params:oauth:grant-type:pre-authorized_code mosip.certify.oauth.response-types-supported=code mosip.certify.oauth.code-challenge-methods-supported=S256 mosip.certify.oauth.interactive-authorization-endpoint=${mosip.certify.authorization.url}${server.servlet.path}/oauth/iae
-
Local VP Request Configuration:
application-local.propertiespointsmosip.certify.vp-request.config-file-urltovp_request_config-local.json. This file contains hardcodedclientIdandnoncevalues that match the sample DCQL VP token used by the Postman collection, so the embedded Inji Verify library's signature / domain / challenge checks pass without regenerating a VP for every run. Deployment configurations should continue to usevp_request_config.json(no hardcodedclientId/nonce). -
Import the Presentation During Issuance VCI collection and the respective environment to test the flow, running the requests in order:
-
Use the
1. Discovery Endpoints Copyfolder to fetch the issuer and OAuth authorization-server metadata endpoints. -
Use
2.1 Auth requestto send the Interactive Authorization Request (IAR) and receive theopenid4vp_requestcarrying the DCQL query. -
Use
3.1 Auth Request with VP (iae_post)to submit thevp_tokenand obtain the authorization code. -
Use
4.1 Successful Token Exchangeto exchange the code for an access token,5.1 Get Nonceto fetch thec_nonce, and finally6.1 Get Credentialto request the VC.
The above README can be used to setup the CSV Plugin and it'll help showcase how one can setup a custom authored plugin for local testing.
Pre-requisites:
- a working Authorization service which gives an identifiable information in the end-user's ID in the
subfield - pre-populated CSV file configured with the matching identities to be authenticated against