mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-20 22:21:09 +02:00
* move files around * move fetches to config to the configuration.index route * working... for aws, lots of clean up left * move error handling to parent route * standarize configModel param * add test coverage * welp a miss for non configurable engines * pr comments * remove mirage interrupts and test actual api * update configuration details test to test for template only things * api error coverage
83 lines
2.2 KiB
TypeScript
83 lines
2.2 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
|
|
import type SecretEngineModel from 'vault/models/secret-engine';
|
|
import type { TtlEvent } from 'vault/app-types';
|
|
|
|
/**
|
|
* @module ConfigureAwsComponent
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <SecretEngine::ConfigureAws
|
|
@model={{model}}
|
|
@tab={{tab}}
|
|
@accessKey={{accessKey}}
|
|
@secretKey={{secretKey}}
|
|
@region={{region}}
|
|
@iamEndpoint={{iamEndpoint}}
|
|
@stsEndpoint={{stsEndpoint}}
|
|
@saveAWSRoot={{action "save" "saveAWSRoot"}}
|
|
@saveAWSLease={{action "save" "saveAWSLease"}} />
|
|
* ```
|
|
*
|
|
* @param {object} model - aws secret engine model
|
|
* @param {string} tab - current tab selection
|
|
* @param {string} accessKey - AWS access key
|
|
* @param {string} secretKey - AWS secret key
|
|
* @param {string} region - AWS region
|
|
* @param {string} iamEndpoint - IAM endpoint
|
|
* @param {string} stsEndpoint - Sts endpoint
|
|
* @param {Function} saveAWSRoot - parent action which saves AWS root credentials
|
|
* @param {Function} saveAWSLease - parent action which updates AWS lease information
|
|
*
|
|
*/
|
|
|
|
type AWSRootCredsFields = {
|
|
access_key: string | null;
|
|
iam_endpoint: string | null;
|
|
sts_endpoint: string | null;
|
|
secret_key: string | null;
|
|
region: string | null;
|
|
};
|
|
|
|
type LeaseFields = { lease: string; lease_max: string };
|
|
|
|
interface Args {
|
|
model: SecretEngineModel;
|
|
tab?: string;
|
|
accessKey: string;
|
|
secretKey: string;
|
|
region: string;
|
|
iamEndpoint: string;
|
|
stsEndpoint: string;
|
|
saveAWSRoot: (data: AWSRootCredsFields) => void;
|
|
saveAWSLease: (data: LeaseFields) => void;
|
|
}
|
|
|
|
export default class ConfigureAwsComponent extends Component<Args> {
|
|
@action
|
|
saveRootCreds(data: AWSRootCredsFields, event: Event) {
|
|
event.preventDefault();
|
|
this.args.saveAWSRoot(data);
|
|
}
|
|
|
|
@action
|
|
saveLease(data: LeaseFields, event: Event) {
|
|
event.preventDefault();
|
|
this.args.saveAWSLease(data);
|
|
}
|
|
|
|
@action
|
|
handleTtlChange(name: string, ttlObj: TtlEvent) {
|
|
// lease values cannot be undefined, set to 0 to use default
|
|
const valueToSet = ttlObj.enabled ? ttlObj.goSafeTimeString : 0;
|
|
this.args.model.set(name, valueToSet);
|
|
}
|
|
}
|