mirror of
https://github.com/hashicorp/vault.git
synced 2025-09-19 12:51:08 +02:00
* updates auth method options route to use form and api client * updates auth method config and section routes to use api client and open api form * updates display attrs for auth method configs * fixes plugin identity util fields tests * fixes js lint error * updates enable-tune-form tests * hides specific form field for jwt/oidc auth config types * Revert "updates display attrs for auth method configs" This reverts commit 5d382f79276f56b3fdbe64fcbc9c8365c5f4b421. * Revert "fixes plugin identity util fields tests" This reverts commit 6d4acbe3228c796745f2dea6279c1540bb053c62. * fixes config section test * bumps api client version * updates auth config form options component to use proper endpoint * fixes enable tune form tests * fixes auth config form options tests * fixes type errors in snapshot-manage component * updates recover_source_path arg to undefined so it is not included in the query params * fixes remaining test failures related to user_lockout_config --------- Co-authored-by: Vault Automation <github-team-secure-vault-core@hashicorp.com>
88 lines
3.0 KiB
TypeScript
88 lines
3.0 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { service } from '@ember/service';
|
|
import { task } from 'ember-concurrency';
|
|
import { waitFor } from '@ember/test-waiters';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { supportedTypes } from 'vault/utils/auth-form-helpers';
|
|
|
|
import type AuthMethodForm from 'vault/forms/auth/method';
|
|
import type ApiService from 'vault/services/api';
|
|
import type FlashMessageService from 'vault/services/flash-messages';
|
|
import type RouterService from '@ember/routing/router-service';
|
|
import type { HTMLElementEvent } from 'vault/forms';
|
|
import type NamespaceService from 'vault/services/namespace';
|
|
import type VersionService from 'vault/services/version';
|
|
import type { MountsAuthTuneConfigurationParametersRequest } from '@hashicorp/vault-client-typescript';
|
|
|
|
/**
|
|
* @module AuthConfigForm/Options
|
|
* The `AuthConfigForm/Options` is options portion of the auth config form.
|
|
*
|
|
* @example
|
|
* <AuthConfigForm::Options @form={{this.form}} />
|
|
*
|
|
* @property form=null {AuthMethodForm} - The corresponding auth method that is being configured.
|
|
*
|
|
*/
|
|
|
|
type Args = {
|
|
form: AuthMethodForm;
|
|
};
|
|
|
|
export default class AuthConfigOptions extends Component<Args> {
|
|
@service declare readonly api: ApiService;
|
|
@service declare readonly flashMessages: FlashMessageService;
|
|
@service declare readonly router: RouterService;
|
|
@service declare readonly namespace: NamespaceService;
|
|
@service declare readonly version: VersionService;
|
|
|
|
@tracked errorMessage: string | null = null;
|
|
|
|
get directLoginLink() {
|
|
const ns = this.namespace.path;
|
|
const nsQueryParam = ns ? `namespace=${encodeURIComponent(ns)}&` : '';
|
|
const { normalizedType, data } = this.args.form;
|
|
const isSupported = supportedTypes(this.version.isEnterprise).includes(normalizedType);
|
|
return isSupported
|
|
? `${window.origin}/ui/vault/auth?${nsQueryParam}with=${encodeURIComponent(data.path)}`
|
|
: '';
|
|
}
|
|
|
|
get supportsUserLockoutConfig() {
|
|
return ['approle', 'ldap', 'userpass'].includes(this.args.form.normalizedType);
|
|
}
|
|
|
|
onSubmit = task(
|
|
waitFor(async (evt: HTMLElementEvent<HTMLFormElement>) => {
|
|
evt.preventDefault();
|
|
this.errorMessage = null;
|
|
try {
|
|
const { form } = this.args;
|
|
const {
|
|
data: { description, config, user_lockout_config },
|
|
} = form.toJSON();
|
|
const payload = {
|
|
description,
|
|
...config,
|
|
} as MountsAuthTuneConfigurationParametersRequest;
|
|
|
|
if (Object.keys(user_lockout_config).length) {
|
|
payload.user_lockout_config = user_lockout_config;
|
|
}
|
|
|
|
await this.api.sys.mountsAuthTuneConfigurationParameters(form.data.path, payload);
|
|
} catch (err) {
|
|
const { message } = await this.api.parseError(err);
|
|
this.errorMessage = message;
|
|
}
|
|
this.router.transitionTo('vault.cluster.access.methods').followRedirects();
|
|
this.flashMessages.success('The configuration was saved successfully.');
|
|
})
|
|
);
|
|
}
|