Socket
Book a DemoInstallSign in
Socket

@pm4ml/connection-manager-api

Package Overview
Dependencies
Maintainers
4
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pm4ml/connection-manager-api

ModusBox Connection Manager API

npmnpm
Version
3.0.0-snapshot.17
Version published
Weekly downloads
152
34.51%
Maintainers
4
Weekly downloads
 
Created
Source

Connection Manager API

Release

Connection Manager API is a component of the Mojaloop ecosystem that allows an administrator to manage the network configuration and PKI information for the Hub and a set of DFSPs.

It provides a REST API, described using a Swagger/OpenAPI document.

The current version uses both cfssl and openssl as the PKI engines which issue and process CSRs and Certificates. The specific version of cfssl that MCM depends on is kept in the Dockerfile as the value of the branch argument ( as in --branch=v1.3.4 ) and can also be specified as an environment variable ( see CFSSL_VERSION below ).

Authentication

The Connection Manager API supports two types of authentication methods for different client types:

  • Browser Clients (SPA): Cookie-based authentication with MySQL session store
  • Machine Clients: JWT/Bearer token authentication via Keycloak

Authentication is implemented using OpenID Connect (OIDC) with PKCE for enhanced security.

See Authentication Documentation for details.

OpenID Connect Authentication

The system uses OpenID Connect authentication, which is a provider-agnostic approach for authentication and authorization. Configure the following environment variables to enable OpenID Connect:

Environment variableDescriptionDefault Value
OPENID_ENABLEDEnable OpenID Connect authenticationfalse
OPENID_DISCOVERY_URLOpenID Connect discovery URL
OPENID_CLIENT_IDClient ID for OpenID authentication
OPENID_CLIENT_SECRETClient secret for OpenID authentication
OPENID_REDIRECT_URIRedirect URI for OpenID authenticationhttp://localhost:3001/api/auth/callback
OPENID_JWT_COOKIE_NAMECookie name for storing the JWT tokenMCM-API_ACCESS_TOKEN
OPENID_EVERYONE_ROLERole assigned to all authenticated userseveryone
OPENID_MTA_ROLEDFSP Admin role mapping for OpenIDmta
OPENID_PTA_ROLEHUB Admin role mapping for OpenIDpta

Password Reset

For OpenID Connect authentication, password reset functionality is handled by the identity provider's own interface rather than through the Connection Manager API. This approach ensures compatibility with any standards-compliant OpenID provider.

Running the server locally

To run the server with all the defaults and no security, the simplest way is to run:

P12_PASS_PHRASE="choose your own password" npm start

The default config requires a mysql db running on the default port.

Once running, you can access the Swagger UI interface

Running the server + db + web UI locally while developing

The API server requires a mysql db. There's also a Web UI https://github.com/modusbox/connection-manager-ui.

To run them together, you can use the following setup:

  • Clone this repo and the Web UI repo at the same level
  • Use the docker-compose config in this repo to run a mysql DB, the WebUI and the API server
mkdir modusbox
cd modusbox
git clone https://github.com/modusbox/connection-manager-ui
git clone https://github.com/modusbox/connection-manager-api
cd connection-manager-api/docker
docker-compose build
docker-compose up

Once the docker containers are confirmed to be stable and up, you will need to create the initial HUB environment. From a new terminal session, execute the following;

curl -X POST "http://localhost:3001/api/environments" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"name\": \"DEV\", \"defaultDN\": { \"CN\": \"tes1.centralhub.modusbox.live\", \"O\": \"Modusbox\", \"OU\": \"MCM\" }}"

The UI 'localhost' can now be opened in your local browser.

If you want to start the app with auth enabled:

  • create a local copy of docker-compose-auth.yml as in:

cp docker-compose-auth.yml docker-compose-auth.local.yml

( docker-compose-auth.local.yml is git-ignored )

  • Edit docker-compose-auth.local.yml and enter the security details.

  • Run the bundle with:

docker-compose build && docker-compose -f docker-compose.yml -f docker-compose-auth.local.yml up

Configuration

There's a Constants.js file that pulls the values from the environment or uses defaults if not defined.

Variables:

Environment variableDescriptionDefault Value
MCM API server configuration
PORTmcm API HTTP port3001
Authentication features
OPENID_ENABLEDEnables support for OAuth2. 'TRUE' to enable(disabled)
OPENID_ENABLE_2FAEnables two-factor authentication 'TRUE' to enable(disabled)
Session configuration
SESSION_STORE_SECRETSecret for encrypting session data
SESSION_MAX_AGESession timeout in milliseconds86400000 (24 hours)
SESSION_SAME_SITESameSite cookie setting'strict'
SESSION_SECUREWhether session cookies require HTTPStrue in production
OAuth2 roles
MTA_ROLEDFSP Admin role'Application/MTA'
PTA_ROLEHUB Admin Role'Application/PTA'
EVERYONE_ROLEAuthenticated users role'Internal/everyone'
Database configuration
DATABASE_HOSTmysql hostlocalhost
DATABASE_PORTmysql port3306
DATABASE_USERmysql usermcm
DATABASE_PASSWORDmysql passwordmcm
DATABASE_SCHEMAmysql schemamcm
DB_RETRIESTimes the initial connection to the DB will be retried10,
DB_CONNECTION_RETRY_WAIT_MILLISECONDSPause between retries5000,
RUN_MIGRATIONSIf true, run db schema migration at startup. Can always be true as the schema creation is idempotenttrue,
CURRENCY_CODESPath to file containing all the supported currency codes'./data/currencyCodes.json',
DATA_CONFIGURATION_FILEInitial data configuration path. See specific doc'./data/sampleConfiguration.json'
MCM Internal Certificate Authority configuration
P12_PASS_PHRASEPass phrase used to save the internal CA Key in the DB.
Support for self-signed certificates on OAuth Server and other TLS client connections
EXTRA_CERTIFICATE_CHAIN_FILE_NAMEExtra trusted server certificate chain file name ( PEM-encoded, as explained in https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options )
EXTRA_ROOT_CERT_FILE_NAMEExtra trusted server root certificate file name
CFSSL
CFSSL_VERSIONExpected CFSSL version to use. Should be updated to keep in sync with the cfssl development1.3.4
CFSSL_COMMAND_PATHcfssl command; it should be just cfssl if it's in the PATH or the full pathcfssl
Keycloak Integration
KEYCLOAK_ENABLEDEnable Keycloak integration for DFSP account creationfalse
KEYCLOAK_BASE_URLBase URL of the Keycloak serverhttp://localhost:8080
KEYCLOAK_DISCOVERY_URLOpenID Connect discovery URL for Keycloakhttp://localhost:8080/realms/dfsps/.well-known/openid-configuration
KEYCLOAK_ADMIN_CLIENT_IDClient ID for Keycloak admin operationsconnection-manager-client
KEYCLOAK_ADMIN_CLIENT_SECRETClient secret for Keycloak admin operations
KEYCLOAK_DFSPS_REALMKeycloak realm for DFSP accountsdfsps
KEYCLOAK_AUTO_CREATE_ACCOUNTSAutomatically create Keycloak accounts when DFSPs are createdtrue

Testing

  • Unit testing:
    • run npm run backend:start as a pre-requisite to npm test
    • run npm test. The tests are implemented using jest. If you need some test certificates, see the test resources readme
  • Smoke testing ( zsh script ): run the cmd-line-tester.sh script from a tmp directory
  • swagger: see "running the server" below

Functional Tests

Refer to README.

Style

js-semistandard-style ( + dangling commas on Objects )

Building a docker image

The server includes a Dockerfile.

There's a set of scripts to build the image and tag it for a local minikube or other environments. Take a look at ./docker-build.sh

Keywords

swagger

FAQs

Package last updated on 12 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts