feat: 🎸 vault ldap CRUDL support
This commit is contained in:
1 parent
3b7873302b
commit
c91771e152
18 files changed
+564
-165
No files matched your search
@@ -0,0 +1,51 @@
|
||||
{{!
|
||||
Copyright (c) HashiCorp, Inc.
|
||||
SPDX-License-Identifier: BUSL-1.1
|
||||
}}
|
||||
|
||||
<Form::Field::ListWrapper
|
||||
@layout='horizontal'
|
||||
@isOptional={{true}}
|
||||
@disabled={{@disabled}}
|
||||
>
|
||||
<:fieldset as |F|>
|
||||
<F.Legend>
|
||||
{{t
|
||||
'resources.credential-library.form.credential_mapping_overrides.label'
|
||||
}}
|
||||
</F.Legend>
|
||||
<F.HelperText>
|
||||
{{t
|
||||
'resources.credential-library.form.credential_mapping_overrides.help'
|
||||
}}
|
||||
</F.HelperText>
|
||||
|
||||
{{#if @model.errors.credential_mapping_overrides}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.credential_mapping_overrides as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</:fieldset>
|
||||
|
||||
<:field as |F|>
|
||||
<F.KeyValue
|
||||
@name='credential_mapping_overrides'
|
||||
@model={{@model}}
|
||||
@disabled={{@disabled}}
|
||||
@width='100%'
|
||||
@showNewRow={{this.showNewRow}}
|
||||
>
|
||||
<:newKey as |N|>
|
||||
<N.select @selectOptions={{this.selectOptions}} />
|
||||
</:newKey>
|
||||
<:key as |K|>
|
||||
<K.select @selectOptions={{this.mappingOverrides}} />
|
||||
</:key>
|
||||
<:value as |V|>
|
||||
<V.text />
|
||||
</:value>
|
||||
</F.KeyValue>
|
||||
</:field>
|
||||
</Form::Field::ListWrapper>
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import { options } from 'api/models/credential-library';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class FormCredentialLibraryMappingOverridesComponent extends Component {
|
||||
get mappingOverrides() {
|
||||
return options.mapping_overrides[this.args.model.credential_type];
|
||||
}
|
||||
|
||||
get allowedEntries() {
|
||||
return this.mappingOverrides.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents users from selecting duplicate keys from the select list if the arg is set to true
|
||||
* @type {array}
|
||||
*/
|
||||
get selectOptions() {
|
||||
const previouslySelectedKeys =
|
||||
this.args.model.credential_mapping_overrides || [];
|
||||
if (previouslySelectedKeys.length) {
|
||||
return this.mappingOverrides.filter((key) =>
|
||||
previouslySelectedKeys.every((obj) => obj.key !== key),
|
||||
);
|
||||
} else {
|
||||
return this.mappingOverrides;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if we need to show an empty row to the users to enter more key/value pairs based on removeDuplicates arg,
|
||||
* by default it is true
|
||||
* @type {object}
|
||||
*/
|
||||
@action
|
||||
showNewRow() {
|
||||
return (
|
||||
this.args.model.credential_mapping_overrides?.length !==
|
||||
this.allowedEntries
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{{!
|
||||
Copyright (c) HashiCorp, Inc.
|
||||
SPDX-License-Identifier: BUSL-1.1
|
||||
}}
|
||||
|
||||
<Hds::Form::RadioCard::Group
|
||||
@name={{t 'form.type.label'}}
|
||||
@alignment='center'
|
||||
as |G|
|
||||
>
|
||||
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
||||
{{#each this.credentialTypes as |type|}}
|
||||
<G.RadioCard
|
||||
@value={{type}}
|
||||
@maxWidth='20rem'
|
||||
@checked={{eq type @model.type}}
|
||||
{{on 'input' (fn @changeType type)}}
|
||||
as |R|
|
||||
>
|
||||
<R.Label>{{t
|
||||
(concat 'resources.credential-library.types.' type)
|
||||
}}</R.Label>
|
||||
<R.Description>{{t
|
||||
(concat 'resources.credential-library.help.' type)
|
||||
}}</R.Description>
|
||||
</G.RadioCard>
|
||||
{{/each}}
|
||||
</Hds::Form::RadioCard::Group>
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import {
|
||||
TYPES_CREDENTIAL_LIBRARY,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
} from 'api/models/credential-library';
|
||||
import { service } from '@ember/service';
|
||||
|
||||
export default class FormCredentialLibraryRadioComponent extends Component {
|
||||
// =services
|
||||
@service features;
|
||||
|
||||
/**
|
||||
* Returns credential types, filtering out SSH if the feature is disabled.
|
||||
* @returns {Array.<string>}
|
||||
*/
|
||||
get credentialTypes() {
|
||||
let types = TYPES_CREDENTIAL_LIBRARY;
|
||||
return this.features.isEnabled('ssh-target')
|
||||
? types
|
||||
: types.filter(
|
||||
(type) => type !== TYPE_CREDENTIAL_LIBRARY_VAULT_SSH_CERTIFICATE,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -51,30 +51,11 @@
|
||||
{{/if}}
|
||||
</Hds::Form::Textarea::Field>
|
||||
|
||||
{{#if (and @model.isNew (feature-flag 'ssh-target'))}}
|
||||
<Hds::Form::RadioCard::Group
|
||||
@name={{t 'form.type.label'}}
|
||||
@alignment='center'
|
||||
as |G|
|
||||
>
|
||||
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
||||
{{#each this.types as |type|}}
|
||||
<G.RadioCard
|
||||
@value={{type}}
|
||||
@maxWidth='20rem'
|
||||
@checked={{eq type @model.type}}
|
||||
{{on 'input' (fn @changeType type)}}
|
||||
as |R|
|
||||
>
|
||||
<R.Label>{{t
|
||||
(concat 'resources.credential-library.types.' type)
|
||||
}}</R.Label>
|
||||
<R.Description>{{t
|
||||
(concat 'resources.credential-library.help.' type)
|
||||
}}</R.Description>
|
||||
</G.RadioCard>
|
||||
{{/each}}
|
||||
</Hds::Form::RadioCard::Group>
|
||||
{{#if @model.isNew}}
|
||||
<Form::CredentialLibrary::Radio
|
||||
@model={{@model}}
|
||||
@changeType={{@changeType}}
|
||||
/>
|
||||
{{else}}
|
||||
<InfoField
|
||||
@value={{t (concat 'resources.credential-library.types.' @model.type)}}
|
||||
@@ -164,52 +145,10 @@
|
||||
{{/if}}
|
||||
|
||||
{{#if @model.credential_type}}
|
||||
<Form::Field::ListWrapper
|
||||
@layout='horizontal'
|
||||
@isOptional={{true}}
|
||||
<Form::CredentialLibrary::MappingOverrides
|
||||
@model={{@model}}
|
||||
@disabled={{form.disabled}}
|
||||
>
|
||||
<:fieldset as |F|>
|
||||
<F.Legend>
|
||||
{{t
|
||||
'resources.credential-library.form.credential_mapping_overrides.label'
|
||||
}}
|
||||
</F.Legend>
|
||||
<F.HelperText>
|
||||
{{t
|
||||
'resources.credential-library.form.credential_mapping_overrides.help'
|
||||
}}
|
||||
</F.HelperText>
|
||||
|
||||
{{#if @model.errors.credential_mapping_overrides}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.credential_mapping_overrides as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</:fieldset>
|
||||
|
||||
<:field as |F|>
|
||||
<F.KeyValue
|
||||
@name='credential_mapping_overrides'
|
||||
@model={{@model}}
|
||||
@disabled={{form.disabled}}
|
||||
@width='100%'
|
||||
@showNewRow={{this.showNewRow}}
|
||||
>
|
||||
<:newKey as |N|>
|
||||
<N.select @selectOptions={{this.selectOptions}} />
|
||||
</:newKey>
|
||||
<:key as |K|>
|
||||
<K.select @selectOptions={{this.mappingOverrides}} />
|
||||
</:key>
|
||||
<:value as |V|>
|
||||
<V.text />
|
||||
</:value>
|
||||
</F.KeyValue>
|
||||
</:field>
|
||||
</Form::Field::ListWrapper>
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<Hds::Form::Radio::Group
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
*/
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import {
|
||||
options,
|
||||
TYPES_CREDENTIAL_LIBRARY,
|
||||
} from 'api/models/credential-library';
|
||||
import { options } from 'api/models/credential-library';
|
||||
import { action } from '@ember/object';
|
||||
export default class FormCredentialLibraryVaultGenericComponent extends Component {
|
||||
// =properties
|
||||
@@ -18,12 +15,6 @@ export default class FormCredentialLibraryVaultGenericComponent extends Componen
|
||||
|
||||
credentialTypes = options.credential_types;
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
types = TYPES_CREDENTIAL_LIBRARY;
|
||||
|
||||
/**
|
||||
* Only allow HTTP request body field if http_method is set to POST.
|
||||
* @type {boolean}
|
||||
@@ -32,14 +23,6 @@ export default class FormCredentialLibraryVaultGenericComponent extends Componen
|
||||
return this.args.model.http_method?.match(/post/i);
|
||||
}
|
||||
|
||||
get mappingOverrides() {
|
||||
return options.mapping_overrides[this.args.model.credential_type];
|
||||
}
|
||||
|
||||
get allowedEntries() {
|
||||
return this.mappingOverrides.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previously selected key value pair when toggling between credential types on a new form
|
||||
*/
|
||||
@@ -48,34 +31,4 @@ export default class FormCredentialLibraryVaultGenericComponent extends Componen
|
||||
this.args.model.credential_mapping_overrides = [];
|
||||
this.args.model.credential_type = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents users from selecting duplicate keys from the select list if the arg is set to true
|
||||
* @type {array}
|
||||
*/
|
||||
|
||||
get selectOptions() {
|
||||
const previouslySelectedKeys =
|
||||
this.args.model.credential_mapping_overrides || [];
|
||||
if (previouslySelectedKeys.length) {
|
||||
return this.mappingOverrides.filter((key) =>
|
||||
previouslySelectedKeys.every((obj) => obj.key !== key),
|
||||
);
|
||||
} else {
|
||||
return this.mappingOverrides;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if we need to show an empty row to the users to enter more key/value pairs based on removeDuplicates arg,
|
||||
* by default it is true
|
||||
* @type {object}
|
||||
*/
|
||||
@action
|
||||
showNewRow() {
|
||||
return (
|
||||
this.args.model.credential_mapping_overrides?.length !==
|
||||
this.allowedEntries
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
{{!
|
||||
Copyright (c) HashiCorp, Inc.
|
||||
SPDX-License-Identifier: BUSL-1.1
|
||||
}}
|
||||
|
||||
<Rose::Form
|
||||
@onSubmit={{@submit}}
|
||||
@cancel={{@cancel}}
|
||||
@disabled={{@model.isSaving}}
|
||||
@showEditToggle={{if @model.isNew false true}}
|
||||
as |form|
|
||||
>
|
||||
<Hds::Form::TextInput::Field
|
||||
name='name'
|
||||
@value={{@model.name}}
|
||||
@isInvalid={{@model.errors.name}}
|
||||
@isOptional={{true}}
|
||||
disabled={{form.disabled}}
|
||||
{{on 'input' (set-from-event @model 'name')}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'form.name.label'}}</F.Label>
|
||||
<F.HelperText>{{t 'form.name.help'}}</F.HelperText>
|
||||
{{#if @model.errors.name}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.name as |error|}}
|
||||
<E.Message>
|
||||
{{error.message}}
|
||||
</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::TextInput::Field>
|
||||
|
||||
<Hds::Form::Textarea::Field
|
||||
name='description'
|
||||
@value={{@model.description}}
|
||||
@isInvalid={{@model.errors.description}}
|
||||
@isOptional={{true}}
|
||||
disabled={{form.disabled}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'form.description.label'}}</F.Label>
|
||||
<F.HelperText>{{t 'form.description.help'}}</F.HelperText>
|
||||
{{#if @model.errors.description}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.description as |error|}}
|
||||
<E.Message>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::Textarea::Field>
|
||||
|
||||
{{#if @model.isNew}}
|
||||
<Form::CredentialLibrary::Radio
|
||||
@model={{@model}}
|
||||
@changeType={{@changeType}}
|
||||
/>
|
||||
{{else}}
|
||||
<InfoField
|
||||
@value={{t (concat 'resources.credential-library.types.' @model.type)}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'form.type.label'}}</F.Label>
|
||||
<F.HelperText>
|
||||
{{t (concat 'resources.credential-library.help.' @model.type)}}
|
||||
</F.HelperText>
|
||||
</InfoField>
|
||||
{{/if}}
|
||||
|
||||
<Hds::Form::TextInput::Field
|
||||
@isRequired={{true}}
|
||||
@isOptional={{false}}
|
||||
@value={{@model.path}}
|
||||
@isInvalid={{@model.errors.path}}
|
||||
@type='text'
|
||||
name='vault_path'
|
||||
disabled={{form.disabled}}
|
||||
{{on 'input' (set-from-event @model 'path')}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t
|
||||
'resources.credential-library.form.vault_path.label'
|
||||
}}</F.Label>
|
||||
<F.HelperText>{{t
|
||||
'resources.credential-library.form.vault_path.help'
|
||||
}}</F.HelperText>
|
||||
{{#if @model.errors.path}}
|
||||
<F.Error as |E|>
|
||||
{{#each @model.errors.path as |error|}}
|
||||
<E.Message
|
||||
data-test-error-message-vault-path
|
||||
>{{error.message}}</E.Message>
|
||||
{{/each}}
|
||||
</F.Error>
|
||||
{{/if}}
|
||||
</Hds::Form::TextInput::Field>
|
||||
|
||||
<InfoField
|
||||
@value={{t
|
||||
(concat 'resources.credential-library.titles.' @model.credential_type)
|
||||
}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t
|
||||
'resources.credential-library.form.credential_type.label'
|
||||
}}</F.Label>
|
||||
<F.HelperText>
|
||||
{{t 'resources.credential-library.form.credential_type.description'}}
|
||||
</F.HelperText>
|
||||
</InfoField>
|
||||
|
||||
<Form::CredentialLibrary::MappingOverrides
|
||||
@model={{@model}}
|
||||
@disabled={{form.disabled}}
|
||||
/>
|
||||
|
||||
{{#if (can 'save model' @model)}}
|
||||
<form.actions
|
||||
@enableEditText={{t 'actions.edit-form'}}
|
||||
@submitText={{t 'actions.save'}}
|
||||
@cancelText={{t 'actions.cancel'}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
</Rose::Form>
|
||||
@@ -54,29 +54,10 @@
|
||||
</Hds::Form::Textarea::Field>
|
||||
|
||||
{{#if @model.isNew}}
|
||||
<Hds::Form::RadioCard::Group
|
||||
@name={{t 'form.type.label'}}
|
||||
@alignment='center'
|
||||
as |G|
|
||||
>
|
||||
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
||||
{{#each this.types as |type|}}
|
||||
<G.RadioCard
|
||||
@value={{type}}
|
||||
@maxWidth='20rem'
|
||||
@checked={{eq type @model.type}}
|
||||
{{on 'input' (fn @changeType type)}}
|
||||
as |R|
|
||||
>
|
||||
<R.Label>{{t
|
||||
(concat 'resources.credential-library.types.' type)
|
||||
}}</R.Label>
|
||||
<R.Description>{{t
|
||||
(concat 'resources.credential-library.help.' type)
|
||||
}}</R.Description>
|
||||
</G.RadioCard>
|
||||
{{/each}}
|
||||
</Hds::Form::RadioCard::Group>
|
||||
<Form::CredentialLibrary::Radio
|
||||
@model={{@model}}
|
||||
@changeType={{@changeType}}
|
||||
/>
|
||||
{{else}}
|
||||
<InfoField
|
||||
@value={{t (concat 'resources.credential-library.types.' @model.type)}}
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
|
||||
import {
|
||||
options,
|
||||
TYPES_CREDENTIAL_LIBRARY,
|
||||
} from 'api/models/credential-library';
|
||||
import { options } from 'api/models/credential-library';
|
||||
|
||||
export default class FormCredentialLibraryVaultSshCertComponent extends Component {
|
||||
// =properties
|
||||
@@ -18,11 +15,6 @@ export default class FormCredentialLibraryVaultSshCertComponent extends Componen
|
||||
*/
|
||||
keyTypes = options.key_type;
|
||||
|
||||
/**
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
types = TYPES_CREDENTIAL_LIBRARY;
|
||||
|
||||
/**
|
||||
* Boolean to determine if the key bits field should be displayed on the form
|
||||
* @returns {boolean}
|
||||
|
||||
Reference in new issue
Block a user