mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 23:21:08 +02:00
* updates api client vars to snake_case for custom messages * updates api client vars to snake_case for tools * updates api client vars to snake_case for sync * updates api client vars to snake_case for secrets engine * updates api client vars to snake_case for auth * updates api client vars to snake_case for usage * updates api client dep to point to gh repo * fixes custom-messages service unit tests * fixes configure-ssh test * fixes configure-ssh test...again
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Form from 'vault/forms/form';
|
|
import FormField from 'vault/utils/forms/field';
|
|
|
|
import type { Validations } from 'vault/app-types';
|
|
import type { SshConfigureCaRequest } from '@hashicorp/vault-client-typescript';
|
|
|
|
export default class SshConfigForm extends Form<SshConfigureCaRequest> {
|
|
validations: Validations = {
|
|
generate_signing_key: [
|
|
{
|
|
validator(data: SshConfigForm['data']) {
|
|
const { public_key, private_key, generate_signing_key } = data;
|
|
// if generateSigningKey is false, both public and private keys are required
|
|
if (!generate_signing_key && (!public_key || !private_key)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
message: 'Provide a Public and Private key or set "Generate Signing Key" to true.',
|
|
},
|
|
],
|
|
public_key: [
|
|
{
|
|
validator(data: SshConfigForm['data']) {
|
|
const { public_key, private_key } = data;
|
|
// regardless of generateSigningKey, if one key is set they both need to be set.
|
|
return public_key || private_key ? !!(public_key && private_key) : true;
|
|
},
|
|
message: 'You must provide a Public and Private keys or leave both unset.',
|
|
},
|
|
],
|
|
};
|
|
|
|
formFields = [
|
|
new FormField('private_key', 'string', { sensitive: true }),
|
|
new FormField('public_key', 'string', { sensitive: true }),
|
|
new FormField('generate_signing_key', 'boolean'),
|
|
];
|
|
}
|