Add MTLS credentials setup for maven

Add MTLS setup credentials incldufing GHA parameters
to be able to use maven for accessing MTLS protected
maven repo
This commit is contained in:
Pavel Gonchukov 2021-02-18 15:04:27 +01:00
parent ff0054dfbf
commit aed95a356a
No known key found for this signature in database
GPG key ID: AA78DD4317B862F7
14 changed files with 23078 additions and 11818 deletions

View file

@ -4,6 +4,7 @@ import * as auth from './auth';
import * as gpg from './gpg';
import * as constants from './constants';
import * as path from 'path';
import {MavenOpts, isValidOptions} from './maven';
async function run() {
try {
@ -12,6 +13,22 @@ async function run() {
version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true});
}
const mvnOpts: MavenOpts = {
caCert: core.getInput(constants.INPUT_MAVEN_CA_CERT_B64),
keystore: core.getInput(constants.INPUT_MAVEN_KEYSTORE_P12_B64),
password: core.getInput(constants.INPUT_MAVEN_KEYSTORE_PASSWORD),
settings: core.getInput(constants.INPUT_MAVEN_SETTINGS_B64),
securitySettings: core.getInput(
constants.INPUT_MAVEN_SECURITY_SETTINGS_B64
)
};
if (!isValidOptions(mvnOpts)) {
throw new Error(
'Some of the Maven options is empty: please check maven-* parameters'
);
}
const arch = core.getInput(constants.INPUT_ARCHITECTURE, {required: true});
if (!['x86', 'x64'].includes(arch)) {
throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
@ -45,7 +62,13 @@ async function run() {
core.setSecret(gpgPrivateKey);
}
await auth.configAuthentication(id, username, password, gpgPassphrase);
await auth.configAuthentication(
id,
username,
password,
gpgPassphrase,
mvnOpts
);
if (gpgPrivateKey) {
core.info('importing private key');