The Prometheus-X Consent Manager is a service for managing consent within the Prometheus-X ecosystem. It empowers ecosystem administrators to oversee and enforce consent agreements, data/service providers to adhere to consent regulations, and users to manage their consent preferences seamlessly.
Before you begin, ensure you have met the following requirements:
- pnpm package manager installed
- mongodb with replicaset
git clone https://github.com/Prometheus-X-association/consent-manager.git
cd consent-manager
npm install --unsafe-perm
cp .env.sample .env
# Configure your environment variables in .env- Clone the repository from GitHub:
git clone https://github.com/Prometheus-X-association/consent-manager.git - Navigate to the project directory:
cd consent-managerand copy the .env.sample to .envcp .env.sample .env - Configure the application by setting up the necessary environment variables. You will need to specify database connection details and other relevant settings.
#Example
NODE_ENV=development
PORT=3000
APP_ENDPOINT=http://localhost:3000
MONGO_URI=mongodb://consent-manager-mongodb:27017/consent-manager
MONGO_URI_TEST=mongodb://consent-manager-mongodb:27017/consent-manager-test
API_PREFIX=/v1
SALT_ROUNDs=10
PDI_ENDPOINT=http://localhost:3331
APPLICATION_NAME=consentmanager-pdi
FEDERATED_APPLICATION_IDENTIFIER=http://localhost:3000
SESSION_COOKIE_NAME=consentmanagersessid
SESSION_SECRET=secret123
JWT_SECRET_KEY=secret123
OAUTH_SECRET_KEY=abc123secret
OAUTH_TOKEN_EXPIRES_IN=1h
CONTRACT_SERVICE_BASE_URL=http://localhost:3000/contracts
# Logs
WINSTON_LOGS_MAX_FILES=14d
WINSTON_LOGS_MAX_SIZE=20m
# Nodemailer
NODEMAILER_HOST=
NODEMAILER_PORT=
NODEMAILER_USER=abc@domain.com
NODEMAILER_PASS=pass
NODEMAILER_FROM_NOREPLY="abc <abc@domain.com>"
#MANDRILL
MANDRILL_ENABLED=false
MANDRILL_API_KEY="yourkey"
MANDRILL_FROM_EMAIL="noreply@visionstrust.com"
MANDRILL_FROM_NAME="noreply"
#Consent
#add multiple by adding ","
PRIVACY_RIGHTS=
WITHDRAWAL_METHOD=
CODE_OF_CONDUCT=
IMPACT_ASSESSMENT=
AUTHORITY_PARTY=
- Create a docker network using
docker network create ptx - Start the application:
docker-compose up -d --build - If you don't want to use the mongodb container from the docker compose you can use the command
docker run -d -p your-port:your-port --name consent-manager consent-managerafter runningdocker-compose build
The consent manager is a work in progress, evolving alongside developments of the Contract and Catalog components of the Prometheus-X Ecosystem.
- Install Terraform: Ensure Terraform is installed on your machine.
- Configure Kubernetes: Ensure you have access to your Kubernetes cluster and kubectl is configured.
- Initialize Terraform: Run the following commands from the terraform directory.
cd terraform
terraform init- Apply the Configuration: Apply the Terraform configuration to create the resources.
terraform apply- Retrieve Service IP: After applying the configuration, retrieve the service IP.
terraform output consent_manager_service_ip
- Replace placeholder values in the
kubernetes_secretresource with actual values from your.env.- Ensure the
server_portvalue matches the port used in your application.- Adjust the
host_pathin thekubernetes_persistent_volumeresource to an appropriate path on your Kubernetes nodes.
-
Install Helm: Ensure Helm is installed on your machine. You can install it following the instructions here.
-
Package the Helm chart:
helm package ./path/to/consent-manager
-
Deploy the Helm chart:
helm install consent-manager ./path/to/consent-manager
-
Verify the deployment:
kubectl get all -n consent-manager
-
Retrieve Service IP:
kubectl get svc -n consent-manager
- Replace placeholder values in the
values.yamlfile with actual values from your.env.- Ensure the
portvalue matches the port used in your application.- Configure your MongoDB connection details in the values.yaml file to point to your managed MongoDB instance.
For a complete list of all available endpoints, along with their request and response schemas, refer to the JSON Swagger Specification provided or visit the github-pages of this repository which displays the swagger specification with the Swagger UI.
The Consent Agent is a component of Prometheus-X that handles the preferences and recommendations of the users. It is integrated into the Consent Manager through the ConsentAgent class, which is responsible for setting up the agent and retrieving the service.
All endpoints, including those related to the Consent Agent, are documented in the JSON Swagger Specification provided in this repository, in the profile section.
For more information on the Consent Agent and its integration with the Consent Manager, please refer to the Consent Agent documentation.
To use the consent agent you must configure the consent-agent.config.sample.json
cp consent-agent.config.sample.json consent-agent.config.jsonAfter copying this file and filling in your information, the Consent Agent will be configured at startup.
The configuration file is a JSON document consisting of sections, where each section describes the configuration for a specific DataProvider. Below is a detailed explanation of the available attributes:
source: The name of the target collection or table that the DataProvider connects to.url: The base URL of the database host.dbName: The name of the database to be used.watchChanges: A boolean that enables or disables change monitoring for the DataProvider. When enabled, events will be fired upon detecting changes.hostsProfiles: A boolean indicating whether the DataProvider hosts the profiles.existingDataCheck: A boolean that enables the creation of profiles when the module is initialized.
Here’s an example of a JSON configuration:
{
"source": "profiles",
"url": "mongodb://localhost:27017",
"dbName": "contract_consent_agent_db",
"watchChanges": false,
"hostsProfiles": true,
"existingDataCheck": true
}- .env file
- Mongodb database with replica-set
- Run tests:
pnpm test-agentThis command will run your tests using Mocha, with test files located at ./src/tests/agent.spec.ts.
- Run tests in docker
docker exec -it consent-manager npm run test-agentBefore using these endpoints you need to signup with a user to get access token
POST /${API_PREFIX}/users/signup
input:
{ "firstName": "john", "lastName": "doe", "email": "john@doe.com", "password": "1234" }output :
{ "user": { "firstName": "john", "lastName": "doe", "email": "john@doe.com", "password": "$2b$10$Vf7EoR.Wp3GxWWb6LUNU1OSgahDppRSOCyU3X0Wan5AcR/88b6BpO", "identifiers": [], "oauth": { "scopes": ["Read user data", "Modify user data"], "refreshToken": "62025bd0886e77f1f895b0d1b9e70c82ef8af61f6232298d7c14bb630bfdf62f" }, "jsonld": "{\n \"@context\": \"http://schema.org\",\n \"@type\": \"Person\",\n \"name\": \"john doe\",\n \"email\": \"john@doe.fr\",\n \"url\": \"undefined:8887/v1/users/67dd2b9d389148595b049e9d\"\n}", "schema_version": "v0.1.0", "_id": "67dd2b9d389148595b049e9d", "createdAt": "2025-03-21T09:04:29.719Z", "updatedAt": "2025-03-21T09:04:29.719Z", "__v": 0 }, "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2N2RkMmI5ZDM4OTE0ODU5NWIwNDllOWQiLCJlbWFpbCI6ImpvaG5AZG9lLmZyIiwic2NvcGVzIjpbIlJlYWQgdXNlciBkYXRhIiwiTW9kaWZ5IHVzZXIgZGF0YSJdLCJpYXQiOjE3NDI1NDc4NjksImV4cCI6MTc0MjU1MTQ2OX0.U67aO9mUn1ITceeQSFpHyA0WuguW9M4zg2cPlTQXNUU", "refreshToken": "62025bd0886e77f1f895b0d1b9e70c82ef8af61f6232298d7c14bb630bfdf62f" }
GET /${API_PREFIX}/profile/${userId}/configurations
headers:
{"Authorization": Bearer JWT}input: -
output :
{ "allowRecommendations": true }
POST /${API_PREFIX}/profile/${userId}/preferences
headers:
{"Authorization": Bearer JWT}input:
{ "preference": [ { "participant": "65eb2661a50cb6465d41865c", "asDataProvider": { "authorizationLevel": "never", "conditions": [ { "time": { "dayOfWeek": ["0"], "startTime": "2024-03-27T14:08:19.986Z", "endTime": "2025-03-27T14:08:19.986Z" } } ] }, "asServiceProvider": { "authorizationLevel": "always", "conditions": [ { "time": { "dayOfWeek": ["0"], "startTime": "2024-03-27T14:08:19.986Z", "endTime": "2025-03-27T14:08:19.986Z" }, "location": { "countryCode": "US" } } ] } } ] }output :
[ { "participant": "65eb2661a50cb6465d41865c", "asDataProvider": { "authorizationLevel": "never", "conditions": [ { "time": { "dayOfWeek": ["0"], "startTime": "2024-03-27T14:08:19.986Z", "endTime": "2025-03-27T14:08:19.986Z" } } ] }, "asServiceProvider": { "authorizationLevel": "always", "conditions": [ { "time": { "dayOfWeek": ["0"], "startTime": "2024-03-27T14:08:19.986Z", "endTime": "2025-03-27T14:08:19.986Z" }, "location": { "countryCode": "US" } } ] }, "_id": "67c7005c5ae3449ac23751de" } ]
For more information see the Tests definition.
We welcome contributions to the Prometheus-X Consent Manager. If you encounter a bug or wish to propose a new feature, kindly open an issue in the GitHub repository. For code contributions, fork the repository, create a new branch, make your changes, and submit a pull request.
The Prometheus-X Consent Manager is open-source software licensed under the MIT License.
