forked from eclipse-tractusx/managed-identity-wallet
-
Notifications
You must be signed in to change notification settings - Fork 1
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 eclipse-tractusx#23 from nitin-vavdiya/features/ja…
…va-did-web Features/java did web feat: merge pull request after skimming through all 60+ files modified.
- Loading branch information
Showing
61 changed files
with
6,917 additions
and
1,121 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 |
---|---|---|
|
@@ -38,7 +38,6 @@ bin/ | |
hs_err_pid*.log | ||
|
||
.env | ||
dev.env | ||
|
||
dev-assets/secrets/* | ||
local.db | ||
|
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,99 @@ | ||
# Managed Identity Wallets <a id="introduction"></a> | ||
|
||
The Managed Identity Wallets (MIW) service implements the Self-Sovereign-Identity (SSI) using did:web | ||
|
||
# Developer Documentation | ||
|
||
To run MIW locally, this section describes the tooling as well as | ||
the local development setup. | ||
|
||
## Tooling | ||
|
||
Following tools the MIW development team used successfully: | ||
|
||
| Area | Tool | Download Link | Comment | | ||
|----------|----------|-------------------------------------------------|---------------------------------------------------------------------------------------------------| | ||
| IDE | IntelliJ | https://www.jetbrains.com/idea/download/ | Additionally the [envfile plugin](https://plugins.jetbrains.com/plugin/7861-envfile) is suggested | | ||
| Build | Gradle | https://gradle.org/install/ | | ||
| Runtime | Docker | https://www.docker.com/products/docker-desktop/ | | | ||
| Database | DBeaver | https://dbeaver.io/ | | ||
| IAM | Keycloak | https://www.keycloak.org/ | | | ||
|
||
## Local Development Setup | ||
|
||
1. Run keycloak and database server using [docker-compose.yaml](dev-assets%2Fdid-web%2Fdocker-compose.yaml) | ||
2. Connect database and create miw database and user to access the database | ||
3. Update DB_USER_NAME, DB_PASSWORD, and DB_NAME in [dev.env](dev-assets%2Fdid-web%2Fdev.env) | ||
4. Create personal access token(classic) with `read:packages` access (ref: https://github.com/settings/tokens/new) | ||
5. set ORG_GRADLE_PROJECT_githubUserName and ORG_GRADLE_PROJECT_githubToken values | ||
in [dev.env](dev-assets%2Fdid-web%2Fdev.env) | ||
6. Setup [dev.env](dev-assets%2Fdid-web%2Fdev.env) values either in application.yaml or in IDE | ||
7. Run [ManagedIdentityWalletsApplication.java](src%2Fmain%2Fjava%2Forg%2Feclipse%2Ftractusx%2Fmanagedidentitywallets%2FManagedIdentityWalletsApplication.java) in IDE | ||
8. Open API doc on http://localhost:8080 | ||
9. Click on Authorize on swagger UI and on the dialog click again on Authorize. | ||
10. Login with username=catena-x and password=password | ||
|
||
## Test Coverage | ||
|
||
Jacoco is used to generate the coverage report. The report generation | ||
and the coverage verification are automatically executed after tests. | ||
|
||
The generated HTML report can be found under `jacoco-report/html/` | ||
|
||
To generate the report run the command | ||
|
||
``` | ||
./gradlew jacocoTestReport | ||
``` | ||
|
||
To check the coverage run the command | ||
|
||
``` | ||
./gradlew jacocoTestCoverageVerification | ||
``` | ||
|
||
Currently the minimum is 80% | ||
|
||
## Environment Variables <a id= "environmentVariables"></a> | ||
|
||
| name | description | default value | | ||
|---------------------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| APPLICATION_PORT | port number of application | 8080 | | ||
| APPLICATION_ENVIRONMENT | Environment of the application ie. local, dev, int and prod | local | | ||
| DB_HOST | Database host | localhost | | ||
| DB_PORT | Port of database | 5432 | | ||
| DB_NAME | Database name | miw | | ||
| USE_SSL | Whether SSL is enabled in database server | false | | ||
| DB_USER_NAME | Database username | | | ||
| DB_PASSWORD | Database password | | | ||
| DB_POOL_SIZE | Max number of database connection acquired by application | 10 | | ||
| KEYCLOAK_MIW_PUBLIC_CLIENT | Only needed if we want enable login with keyalock in swagger | miw_public | | ||
| MANAGEMENT_PORT | Spring actuator port | 8090 | | ||
| MIW_HOST_NAME | Application host name, this will be used in creation of did ie. did:web:MIW_HOST_NAME:BPN | localhost | | ||
| ENCRYPTION_KEY | encryption key used to encrypt and decrypt private and public key of wallet | | | ||
| AUTHORITY_WALLET_BPN | base wallet BPN number | BPNL000000000000 | | ||
| AUTHORITY_WALLET_NAME | Base wallet name | Catena-X | | ||
| AUTHORITY_WALLET_DID | Base wallet web did | web:did:host:BPNL000000000000 | | ||
| VC_SCHEMA_LINK | Comma separated list of VC schema URL | https://www.w3.org/2018/credentials/v1, https://raw.githubusercontent.com/catenax-ng/product-core-schemas/main/businessPartnerData | | ||
| VC_EXPIRY_DATE | Expiry date of VC (dd-MM-yyyy ie. 01-01-2025 expiry date will be 2024-12-31T18:30:00Z in VC) | 01-01-2025 | | ||
| KEYCLOAK_REALM | Realm name of keycloak | miw_test | | ||
| KEYCLOAK_CLIENT_ID | Keycloak private client id | | | ||
| AUTH_SERVER_URL | Keycloak server url | | | ||
| SUPPORTED_FRAMEWORK_VC_TYPES | Supported framework VC, provide values ie type1=value1,type2=value2 | cx-behavior-twin=Behavior Twin,cx-pcf=PCF,cx-quality=Quality,cx-resiliency=Resiliency,cx-sustainability=Sustainability,cx-traceability=ID_3.0_Trace | | ||
| ENFORCE_HTTPS_IN_DID_RESOLUTION | Enforce https during web did resolution | true | | ||
| CONTRACT_TEMPLATES_URL | Contract templates URL used in summary VC | https://public.catena-x.org/contracts/ | | ||
| | | | | ||
|
||
## Technical Debts and Known issue | ||
|
||
1. Keys are stored in database in encrypted format, need to store keys in more secure place ie. Vault | ||
2. Policies can be validated dynamically as per | ||
request while validating VP and | ||
VC. [Check this for more details](https://docs.walt.id/v/ssikit/concepts/verification-policies) | ||
|
||
## Reference of external lib | ||
|
||
1. https://www.testcontainers.org/modules/databases/postgres/ | ||
2. https://github.com/dasniko/testcontainers-keycloak | ||
3. https://github.com/smartSenseSolutions/smartsense-java-commons | ||
4. https://github.com/catenax-ng/product-lab-ssi |
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,29 @@ | ||
#application env variables need to setup in IDE | ||
APPLICATION_PORT=8080 | ||
APPLICATION_ENVIRONMENT=dev | ||
DB_HOST=localhost | ||
DB_PORT=5432 | ||
USE_SSL=false | ||
|
||
|
||
#create miw database and update below properties | ||
DB_USER_NAME= | ||
DB_PASSWORD= | ||
DB_NAME= | ||
KEYCLOAK_MIW_PUBLIC_CLIENT=miw_public | ||
MANAGEMENT_PORT=8090 | ||
MIW_HOST_NAME=localhost | ||
ENCRYPTION_KEY=Woh9waid4Ei5eez0aitieghoow9so4oe | ||
AUTHORITY_WALLET_BPN=BPNL000000000000 | ||
AUTHORITY_WALLET_NAME=Catena-X | ||
AUTHORITY_WALLET_DID:did:web:localhost:BPNL000000000000 | ||
VC_SCHEMA_LINK=https://www.w3.org/2018/credentials/v1, https://raw.githubusercontent.com/catenax-ng/product-core-schemas/main/businessPartnerData | ||
VC_EXPIRY_DATE=01-01-2025 | ||
SUPPORTED_FRAMEWORK_VC_TYPES=cx-behavior-twin=Behavior Twin,cx-pcf=PCF,cx-quality=Quality,cx-resiliency=Resiliency,cx-sustainability=Sustainability,cx-traceability=ID_3.0_Trace | ||
KEYCLOAK_REALM=miw_test | ||
KEYCLOAK_CLIENT_ID=miw_private_client | ||
AUTH_SERVER_URL=http://localhost:8081 | ||
|
||
## Github user name | ||
ORG_GRADLE_PROJECT_githubUserName= | ||
ORG_GRADLE_PROJECT_githubToken= |
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' | ||
|
||
volumes: | ||
postgres_data: | ||
driver: local | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_DB: keycloak | ||
POSTGRES_USER: keycloak | ||
POSTGRES_PASSWORD: password | ||
ports: | ||
- "5432:5432" | ||
keycloak: | ||
image: quay.io/keycloak/keycloak:21.0.2 | ||
environment: | ||
DB_VENDOR: POSTGRES | ||
DB_ADDR: postgres | ||
DB_DATABASE: keycloak | ||
DB_USER: keycloak | ||
DB_SCHEMA: public | ||
DB_PASSWORD: password | ||
KEYCLOAK_ADMIN: admin | ||
KEYCLOAK_ADMIN_PASSWORD: admin | ||
entrypoint: [ "/opt/keycloak/bin/kc.sh", "start-dev" ,"--import-realm" ] | ||
volumes: | ||
- ./miw_test_realm.json:/opt/keycloak/data/import/miw_test_realm.json | ||
ports: | ||
- 8081:8080 | ||
depends_on: | ||
- postgres |
Oops, something went wrong.