diff --git a/addons/api/addon/models/credential-library.js b/addons/api/addon/models/credential-library.js index 4ca321a18..a77e605ba 100644 --- a/addons/api/addon/models/credential-library.js +++ b/addons/api/addon/models/credential-library.js @@ -6,7 +6,7 @@ import { fragment } from 'ember-data-model-fragments/attributes'; * Enum options for credential library. */ export const options = { - http_methods: ['GET', 'POST'], + http_method: ['GET', 'POST'], }; export default class CredentialLibraryModel extends GeneratedCredentialLibraryModel { @@ -15,11 +15,7 @@ export default class CredentialLibraryModel extends GeneratedCredentialLibraryMo // See the application adapter's error normalization method for // more information. - @attr('string', { - readOnly: true, - defaultValue: options.http_methods[0], - }) - attributes_http_method; + @attr('string', { readOnly: true }) attributes_http_method; @attr('string', { readOnly: true }) attributes_http_request_body; @attr('string', { readOnly: true }) attributes_path; diff --git a/addons/api/addon/models/fragment-credential-library-attributes.js b/addons/api/addon/models/fragment-credential-library-attributes.js index dd6138199..582922601 100644 --- a/addons/api/addon/models/fragment-credential-library-attributes.js +++ b/addons/api/addon/models/fragment-credential-library-attributes.js @@ -1,5 +1,6 @@ import Fragment from 'ember-data-model-fragments/fragment'; import { attr } from '@ember-data/model'; +import { options } from './credential-library'; export default class FragmentCredentialLibraryAttributesModel extends Fragment { //= attributes (vault) @@ -7,6 +8,7 @@ export default class FragmentCredentialLibraryAttributesModel extends Fragment { @attr('string', { description: 'The HTTP method the library uses when requesting credentials from Vault.', + defaultValue: () => options.http_method[0], }) http_method; diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 5d9ddaf8e..a45cd1bab 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -484,7 +484,6 @@ export default function () { const attrs = this.normalizedRequestAttrs(); const credentialStore = credentialStores.find(attrs.credentialStoreId); attrs.scopeId = credentialStore.scope.id; - console.log(attrs); return credentialLibraries.create(attrs); } ); diff --git a/addons/core/translations/form/en-us.yaml b/addons/core/translations/form/en-us.yaml index 171011a4a..cb7b69832 100644 --- a/addons/core/translations/form/en-us.yaml +++ b/addons/core/translations/form/en-us.yaml @@ -115,12 +115,3 @@ value: callback_url: label: Callback URL help: The URL to which the third-party provider sends the authentication response. Paste this into the provider configuration. -vault_path: - label: Vault Path - help: The path in Vault to request credentials from. -http_method: - label: HTTP Method - help: The HTTP method the library uses when requesting credentials from Vault. -http_request_body: - label: HTTP Request Body - help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when http_method is set to POST. diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 9468e3500..d889b0975 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -280,4 +280,17 @@ credential-library: messages: none: title: No Credential Libraries Available - description: No Credential Libraries available in this credential store. \ No newline at end of file + description: No Credential Libraries available in this credential store. + form: + vault_path: + label: Vault Path + help: The path the library uses when requesting credentials from Vault. + http_method: + label: HTTP Method + help: The HTTP method the library uses when requesting credentials from Vault. + http_request_body: + label: HTTP Request Body + help: The body of the HTTP request the library sends to Vault when requesting credentials. Only allowed when HTTP method is set to POST. + http_post_method_options: + label: HTTP Method POST Options + help: The options available for when HTTP method is set to POST. \ No newline at end of file diff --git a/ui/admin/app/components/form/credential-library/index.hbs b/ui/admin/app/components/form/credential-library/index.hbs index 322c35965..f55445503 100644 --- a/ui/admin/app/components/form/credential-library/index.hbs +++ b/ui/admin/app/components/form/credential-library/index.hbs @@ -48,15 +48,15 @@ @name='vault_path' @type='text' @value={{@model.attributes.path}} - @label={{t 'form.vault_path.label'}} - @error={{@model.errors.name}} - @helperText={{t 'form.vault_path.help'}} + @label={{t 'resources.credential-library.form.vault_path.label'}} + @error={{@model.errors.attributes_path}} + @helperText={{t 'resources.credential-library.form.vault_path.help'}} readonly={{false}} as |field| > - {{#if @model.errors.name}} + {{#if @model.errors.attributes_path}} - {{#each @model.errors.name as |error|}} + {{#each @model.errors.attributes_path as |error|}} {{error.message}} {{/each}} @@ -64,8 +64,10 @@ - <:title>{{t 'form.http_method.label'}} - <:description>{{t 'form.http_method.help'}} + <:title>{{t 'resources.credential-library.form.http_method.label'}} + <:description>{{t + 'resources.credential-library.form.http_method.help' + }} <:body> - {{#each this.httpMethods as |httpMethod|}} + {{#each this.httpMethodOptions as |httpMethod|}} {{/each}} - - {{#if @model.errors.description}} - - {{#each @model.errors.description as |error|}} - {{error.message}} - {{/each}} - - {{/if}} - + {{#if this.isHttpRequestBodyAllowed}} + + <:title>{{t + 'resources.credential-library.form.http_post_method_options.label' + }} + <:description>{{t + 'resources.credential-library.form.http_post_method_options.help' + }} + <:body> + + {{#if @model.errors.attributes_http_request_body}} + + {{#each @model.errors.attributes_http_request_body as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{/if}}