Skip to content

Commit

Permalink
refactor(cmd-api-server): clean up configuration parameters #720
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removed the `keyPairPem` parameter from the API server
configuration.

fixes: #720

Parameters cleaned up are: cactusNodeId, consortiumId, keychainSuffixKeyPairPem

Cleaning the three mentioned parameters are backwards compatible with tags
versions: v1.0.0-rc.3 and v1.0.0

The latest tag being used as of this change is v1.0.0-25-gdda3f00c

Signed-off-by: ruzell22 <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
ruzell22 authored and petermetz committed Sep 8, 2023
1 parent 55a1507 commit 1f00d24
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 129 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"configFile": ".config.json",
"authorizationConfigJson" : {},
"cactusNodeId": "972b1aec-a027-4dfb-bf0f-3811ad8d15e4",
"consortiumId": "fb3edae7-46db-4e84-837e-c66f6f2bc78e",
"logLevel": "debug",
"minNodeVersion": "12.0.0",
"tlsDefaultMaxVersion": "TLSv1.3",
Expand All @@ -25,8 +23,6 @@
"cockpitTlsCertPem": "-----BEGIN CERTIFICATE-----\r\nMIIGjjCCBHagAwIBAgIKDv1M8Cl8RNkaBDANBgkqhkiG9w0BAQ0FADCBrzESMBAG\r\nA1UEAxMJbG9jYWxob3N0MREwDwYDVQQGEwhVbml2ZXJzZTESMBAGA1UECBMJTWls\r\na3kgV2F5MRUwEwYDVQQHEwxQbGFuZXQgRWFydGgxFDASBgNVBAoTC0h5cGVybGVk\r\nZ2VyMQ8wDQYDVQQLEwZDYWN0dXMxNDAyBgkqhkiG9w0BCQITJUNhY3R1cyBEdW1t\r\neSBTZWxmIFNpZ25lZCBDZXJ0aWZpY2F0ZXMwHhcNMjEwNDE0MDYwOTU2WhcNMjIw\r\nNDE0MDYwOTU2WjCBrzESMBAGA1UEAxMJbG9jYWxob3N0MREwDwYDVQQGEwhVbml2\r\nZXJzZTESMBAGA1UECBMJTWlsa3kgV2F5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": "-",
"keyPairPem": "-----BEGIN PRIVATE KEY-----\nMIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgHy0hDxj3Uhz16F8aLiWq\nhf6bcqRU3fqAv2u2YvYdSF+hRANCAAQpvM3dbCigeGLDKs0JUTi0yf5UHGC2eSRD\nd3Dk1WpBjbJDLKGdSGVGE0h1Zys8o3Den3Xag8Y1EcTxDHDInMEc\n-----END PRIVATE KEY-----\n",
"keychainSuffixKeyPairPem": "CACTUS_NODE_KEY_PAIR_PEM",
"plugins": [
{
"packageName": "@hyperledger/cactus-plugin-keychain-memory",
Expand Down
2 changes: 0 additions & 2 deletions examples/carbon-accounting/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ COPY --chown=${APP_USER}:${APP_USER} ./examples/carbon-accounting/healthcheck.sh

ENV AUTHORIZATION_CONFIG_JSON="{}"
ENV AUTHORIZATION_PROTOCOL=NONE
ENV CACTUS_NODE_ID=-
ENV CONSORTIUM_ID=-
ENV KEY_PAIR_PEM=-
ENV COCKPIT_WWW_ROOT=/usr/src/app/node_modules/@hyperledger/cactus-example-carbon-accounting-frontend/www/
ENV COCKPIT_TLS_ENABLED=false
Expand Down
2 changes: 0 additions & 2 deletions examples/supply-chain-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ COPY --chown=${APP_USER}:${APP_USER} ./examples/supply-chain-app/healthcheck.sh

ENV AUTHORIZATION_CONFIG_JSON="{}"
ENV AUTHORIZATION_PROTOCOL=NONE
ENV CACTUS_NODE_ID=-
ENV CONSORTIUM_ID=-
ENV KEY_PAIR_PEM=-
ENV COCKPIT_WWW_ROOT=/usr/src/app/node_modules/@hyperledger/cactus-example-supply-chain-frontend/www/
ENV COCKPIT_TLS_ENABLED=false
Expand Down
2 changes: 0 additions & 2 deletions examples/supply-chain-app/process.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
CACTUS_NODE_ID=-
CONSORTIUM_ID=-
KEY_PAIR_PEM=-
COCKPIT_WWW_ROOT=./node_modules/@hyperledger/cactus-example-supply-chain-frontend/www/
COCKPIT_TLS_ENABLED=false
Expand Down
2 changes: 0 additions & 2 deletions packages/cactus-cmd-api-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ ARG NPM_PKG_VERSION=latest
ENV TZ=Etc/UTC
ENV NODE_ENV=production

ENV CACTUS_NODE_ID=-
ENV CONSORTIUM_ID=-
ENV KEY_PAIR_PEM=-
ENV COCKPIT_WWW_ROOT=${APP}node_modules/@hyperledger/cactus-cockpit/www/
ENV COCKPIT_TLS_ENABLED=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,8 @@ import { existsSync, readFileSync } from "fs";
import convict, { Schema, Config, SchemaObj } from "convict";
import { ipaddress } from "convict-format-with-validator";
import { v4 as uuidV4 } from "uuid";
import {
generateKeyPair,
exportPKCS8,
exportSPKI,
importPKCS8,
GeneralSign,
generalVerify,
} from "jose";
import { generateKeyPair, exportPKCS8, exportSPKI } from "jose";
import type { Params as ExpressJwtOptions } from "express-jwt";
import jsonStableStringify from "json-stable-stringify";
import {
LoggerProvider,
Logger,
Expand All @@ -39,8 +31,6 @@ export interface ICactusApiServerOptions {
authorizationProtocol: AuthorizationProtocol;
authorizationConfigJson: IAuthorizationConfig;
configFile: string;
cactusNodeId: string;
consortiumId: string;
logLevel: LogLevelDesc;
tlsDefaultMaxVersion: SecureVersion;
cockpitEnabled: boolean;
Expand All @@ -65,8 +55,6 @@ export interface ICactusApiServerOptions {
grpcPort: number;
grpcMtlsEnabled: boolean;
plugins: PluginImport[];
keyPairPem: string;
keychainSuffixKeyPairPem: string;
minNodeVersion: string;
enableShutdownHook: boolean;
}
Expand Down Expand Up @@ -103,8 +91,7 @@ export class ConfigService {
private static getConfigSchema(): Schema<ICactusApiServerOptions> {
return {
pluginManagerOptionsJson: {
doc:
"Can be used to override npm registry and authentication details for example. See https://www.npmjs.com/package/live-plugin-manager#pluginmanagerconstructoroptions-partialpluginmanageroptions for further details.",
doc: "Can be used to override npm registry and authentication details for example. See https://www.npmjs.com/package/live-plugin-manager#pluginmanagerconstructoroptions-partialpluginmanageroptions for further details.",
format: "*",
default: "{}",
env: "PLUGIN_MANAGER_OPTIONS_JSON",
Expand All @@ -123,7 +110,7 @@ export class ConfigService {
throw new Error(m);
}
},
default: (null as unknown) as AuthorizationProtocol,
default: null as unknown as AuthorizationProtocol,
env: "AUTHORIZATION_PROTOCOL",
arg: "authorization-protocol",
},
Expand Down Expand Up @@ -173,31 +160,12 @@ export class ConfigService {
},
} as SchemaObj<PluginImport[]>,
configFile: {
doc:
"The path to a config file that holds the configuration itself which will be parsed and validated.",
doc: "The path to a config file that holds the configuration itself which will be parsed and validated.",
format: "*",
default: "",
env: "CONFIG_FILE",
arg: "config-file",
},
consortiumId: {
doc:
"Identifier of the consortium your node is part of. " +
" Can be any string of characters such as a UUID",
format: ConfigService.formatNonBlankString,
default: null as string | null,
env: "CONSORTIUM_ID",
arg: "consortium-id",
},
cactusNodeId: {
doc:
"Identifier of this particular Cactus node. Must be unique among the total set of Cactus nodes running in any " +
"given Cactus deployment. Can be any string of characters such as a UUID or an Int64",
format: ConfigService.formatNonBlankString,
default: null as string | null,
env: "CACTUS_NODE_ID",
arg: "cactus-node-id",
},
logLevel: {
doc:
"The level at which loggers should be configured. Supported values include the following: " +
Expand Down Expand Up @@ -243,8 +211,7 @@ export class ConfigService {
default: false,
},
cockpitHost: {
doc:
"The host to bind the Cockpit webserver to. Secure default is: 127.0.0.1. Use 0.0.0.0 to bind for any host.",
doc: "The host to bind the Cockpit webserver to. Secure default is: 127.0.0.1. Use 0.0.0.0 to bind for any host.",
format: "ipaddress",
default: "127.0.0.1",
env: "COCKPIT_HOST",
Expand All @@ -258,8 +225,7 @@ export class ConfigService {
default: 3000,
},
cockpitWwwRoot: {
doc:
"The file-system path pointing to the static files of web application served as the cockpit by the API server.",
doc: "The file-system path pointing to the static files of web application served as the cockpit by the API server.",
format: "*",
env: "COCKPIT_WWW_ROOT",
arg: "cockpit-www-root",
Expand Down Expand Up @@ -331,8 +297,7 @@ export class ConfigService {
default: null as string | null,
},
apiHost: {
doc:
"The host to bind the API to. Secure default is: 127.0.0.1. Use 0.0.0.0 to bind for any host.",
doc: "The host to bind the API to. Secure default is: 127.0.0.1. Use 0.0.0.0 to bind for any host.",
format: "ipaddress",
env: "API_HOST",
arg: "api-host",
Expand Down Expand Up @@ -417,27 +382,7 @@ export class ConfigService {
arg: "grpc-tls-enabled",
default: true,
},
keyPairPem: {
sensitive: true,
doc:
"Key pair (private+public) of this Cactus node in the standard " +
" PEM format.",
env: "KEY_PAIR_PEM",
arg: "key-pair-pem",
format: ConfigService.formatNonBlankString,
default: null as string | null,
},
keychainSuffixKeyPairPem: {
doc:
"The key under which to store/retrieve the key pair PEM from the " +
" keychain of this Cactus node (API server) The complete lookup key" +
" is constructed from the ${CACTUS_NODE_ID}" +
"${KEYCHAIN_SUFFIX_KEY_PAIR_PEM} template.",
env: "KEYCHAIN_SUFFIX_KEY_PAIR_PEM",
arg: "keychain-suffix-key-pair-pem",
format: "*",
default: "CACTUS_NODE_KEY_PAIR_PEM",
},

enableShutdownHook: {
doc:
"It will cause the API server to listen to OS process signals and will attempt " +
Expand Down Expand Up @@ -613,8 +558,6 @@ export class ConfigService {
authorizationProtocol: AuthorizationProtocol.JSON_WEB_TOKEN,
authorizationConfigJson,
configFile: ".config.json",
cactusNodeId: uuidV4(),
consortiumId: uuidV4(),
logLevel: "debug",
minNodeVersion: (schema.minNodeVersion as SchemaObj).default,
tlsDefaultMaxVersion: "TLSv1.3",
Expand All @@ -639,9 +582,6 @@ export class ConfigService {
cockpitTlsCertPem: pkiServer.certificatePem,
cockpitTlsKeyPem: pkiServer.privateKeyPem,
cockpitTlsClientCaPem: "-", // Cockpit mTLS is off so this will not crash the server
keyPairPem,
keychainSuffixKeyPairPem: (schema.keychainSuffixKeyPairPem as SchemaObj)
.default,
plugins,
enableShutdownHook,
};
Expand All @@ -661,7 +601,8 @@ export class ConfigService {
env?: NodeJS.ProcessEnv;
args?: string[];
}): Config<ICactusApiServerOptions> {
const schema: Schema<ICactusApiServerOptions> = ConfigService.getConfigSchema();
const schema: Schema<ICactusApiServerOptions> =
ConfigService.getConfigSchema();
ConfigService.config = (convict as any)(schema, options);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
if (ConfigService.config.get("configFile")) {
Expand All @@ -680,29 +621,4 @@ export class ConfigService {
logger.info("Configuration validation OK.");
return ConfigService.config;
}

/**
* Validation that prevents operators from mistakenly deploying a key pair
* that they may not be operational for whatever reason.
*
* @throws If a dummy sign+verification operation fails for any reason.
*/
async validateKeyPairMatch(): Promise<void> {
const fnTag = "ConfigService#validateKeyPairMatch()";
// FIXME most of this lowever level crypto code should be in a commons package that's universal
const keyPairPem = ConfigService.config.get("keyPairPem");
const keyPair = await importPKCS8(keyPairPem, "ES256K");

const payloadJson = jsonStableStringify({ hello: "world" });
const encoder = new TextEncoder();
const sign = new GeneralSign(encoder.encode(payloadJson));
sign.addSignature(keyPair).setProtectedHeader({ alg: "ES256K" });
const jws = await sign.sign();

try {
await generalVerify(jws, keyPair);
} catch (ex) {
throw new Error(`${fnTag} Invalid key pair PEM: ${ex && ex.stack}`);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ describe(testCase, () => {
consortiumDatabase: db,
};

const pluginConsortiumManual: PluginConsortiumManual = new PluginConsortiumManual(
options,
);
const pluginConsortiumManual = new PluginConsortiumManual(options);

// Setting up of the api-server for hosting the endpoints defined in the openapi specs
// of the plugin
Expand Down
2 changes: 0 additions & 2 deletions tools/docker/besu-all-in-one/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ services:
cactus-api-server:
image: ghcr.io/hyperledger/cactus-cmd-api-server:2021-08-15--refactor-1222
environment:
CACTUS_NODE_ID: "-"
CONSORTIUM_ID: "-"
KEY_PAIR_PEM: "-"
COCKPIT_WWW_ROOT: ${APP}node_modules/@hyperledger/cactus-cockpit/www/
COCKPIT_TLS_ENABLED: "false"
Expand Down
10 changes: 2 additions & 8 deletions whitepaper/whitepaper.md
Original file line number Diff line number Diff line change
Expand Up @@ -1077,11 +1077,6 @@ Configuration Parameters
Default: Mandatory parameter without a default value.
Env: CONFIG_FILE
CLI: --config-file
cactusNodeId:
Description: Identifier of this particular Cactus node. Must be unique among the total set of Cactus nodes running in any given Cactus deployment. Can be any string of characters such as a UUID or an Int64
Default: Mandatory parameter without a default value.
Env: CACTUS_NODE_ID
CLI: --cactus-node-id
logLevel:
Description: The level at which loggers should be configured. Supported values include the following: error, warn, info, debug, trace
Default: warn
Expand Down Expand Up @@ -1128,12 +1123,12 @@ Configuration Parameters
Env: PRIVATE_KEY
CLI: --private-key
keychainSuffixPrivateKey:
Description: The key under which to store/retrieve the private key from the keychain of this Cactus node (API server)The complete lookup key is constructed from the ${CACTUS_NODE_ID}${KEYCHAIN_SUFFIX_PRIVATE_KEY} template.
Description: The key under which to store/retrieve the private key from the keychain of this Cactus node (API server)The complete lookup key is constructed from the ${KEYCHAIN_SUFFIX_PRIVATE_KEY} template.
Default: CACTUS_NODE_PRIVATE_KEY
Env: KEYCHAIN_SUFFIX_PRIVATE_KEY
CLI: --keychain-suffix-private-key
keychainSuffixPublicKey:
Description: The key under which to store/retrieve the public key from the keychain of this Cactus node (API server)The complete lookup key is constructed from the ${CACTUS_NODE_ID}${KEYCHAIN_SUFFIX_PRIVATE_KEY} template.
Description: The key under which to store/retrieve the public key from the keychain of this Cactus node (API server)The complete lookup key is constructed from the ${KEYCHAIN_SUFFIX_PRIVATE_KEY} template.
Default: CACTUS_NODE_PUBLIC_KEY
Env: KEYCHAIN_SUFFIX_PUBLIC_KEY
CLI: --keychain-suffix-public-key
Expand Down Expand Up @@ -1447,7 +1442,6 @@ seen below:
{
"packageName": "@hyperledger/cactus-plugin-consortium-manual",
"options": {
"keyPairPem": "-----BEGIN PRIVATE KEY-----\nREDACTED\n-----END PRIVATE KEY-----\n",
"consortium": {
"name": "Example Cactus Consortium",
"id": "2ae136f6-f9f7-40a2-9f6c-92b1b5d5046c",
Expand Down
Loading

0 comments on commit 1f00d24

Please sign in to comment.