From 3c61d003dbca0388491a1567dd4363e12d45517b Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 5 Apr 2021 12:49:15 -0600 Subject: [PATCH 01/37] new font and add as font-family to be used in masked-input --- ui/app/styles/app.scss | 9 +++++++++ ui/app/styles/components/masked-input.scss | 8 ++++++++ ui/config/environment.js | 1 + .../addon/templates/components/masked-input.hbs | 13 +++++++------ ui/public/fonts/obscure.woff | Bin 0 -> 1592 bytes ui/public/fonts/obscure.woff2 | Bin 0 -> 888 bytes vault/ui.go | 2 +- 7 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 ui/public/fonts/obscure.woff create mode 100644 ui/public/fonts/obscure.woff2 diff --git a/ui/app/styles/app.scss b/ui/app/styles/app.scss index 7f8fbdb71024..d8385bb21d91 100644 --- a/ui/app/styles/app.scss +++ b/ui/app/styles/app.scss @@ -1,3 +1,12 @@ @import 'ember-basic-dropdown'; @import 'ember-power-select'; @import './core'; + +@mixin font-face($name) { + @font-face { + font-family: $name; + src: url('/ui/fonts/#{$name}.woff2') format('woff2'), url('/ui/fonts/#{$name}.woff') format('woff'); + } +} + +@include font-face('obscure'); diff --git a/ui/app/styles/components/masked-input.scss b/ui/app/styles/components/masked-input.scss index 124f2a1640e1..1b98705a235a 100644 --- a/ui/app/styles/components/masked-input.scss +++ b/ui/app/styles/components/masked-input.scss @@ -1,3 +1,11 @@ +.masked-font { + font-family: obscure; + font-size: $size-medium; + letter-spacing: 2px; + line-height: 2.5; + color: $ui-gray-300; +} + .masked-input { display: flex; align-items: center; diff --git a/ui/config/environment.js b/ui/config/environment.js index 4896b1ad8f77..d8b4be4400f5 100644 --- a/ui/config/environment.js +++ b/ui/config/environment.js @@ -67,6 +67,7 @@ module.exports = function(environment) { ENV.contentSecurityPolicy = { 'connect-src': ["'self'"], 'img-src': ["'self'", 'data:'], + 'font-src': ["'self'"], 'form-action': ["'none'"], 'script-src': ["'self'"], 'style-src': ["'unsafe-inline'", "'self'"], diff --git a/ui/lib/core/addon/templates/components/masked-input.hbs b/ui/lib/core/addon/templates/components/masked-input.hbs index 94ce19a8c27f..b840efe625de 100644 --- a/ui/lib/core/addon/templates/components/masked-input.hbs +++ b/ui/lib/core/addon/templates/components/masked-input.hbs @@ -6,10 +6,11 @@ {{else}} @@ -19,10 +20,10 @@ {{/if}} {{#if allowCopy}} + @clipboardText={{value}} + @success={{action (set-flash-message 'Data copied!')}} + class="copy-button button {{if displayOnly "is-compact"}}" + data-test-copy-button> {{/if}} diff --git a/ui/public/fonts/obscure.woff b/ui/public/fonts/obscure.woff new file mode 100644 index 0000000000000000000000000000000000000000..e714220e23422dc8b1ff8a5d239573cdfe245d27 GIT binary patch literal 1592 zcmZWpdpOf;9Dip_Ew|yYd0b{Hm*dzGxhI!Qii4+zH$121IFbs=-6CCv2#FJqSVg+o2^}s=Y2T3CV zHo`VHnB!rrMmz>F3CVN@Tvw4_0f~wfDM}_Y;CzTEm@67W0Vo7e$;t7s?HmjYTRdVgf6+ouCO0Rk_ReT4RtqT zr7{Ro;wpilpI6!a7c;yti$)?}cHQ!me_Th62YEt30nOp6wg7~{lm4rtj7XM_vj1SS z&+`%;kw|aNEJ|x1B$eJ~p|OR|7!T2yNGJ;FY@QtbLC9RaK3@lG4&rsOSVX#|nqokP z;OzZ2|Beu>WPWl(;6lHB14e(9zgvrolhfc+s!bc>RmhDJz1tdX>O_&)Z_cY#$z1G5 z(-tV3AFc{M>cGie$sTnU$e*tPtPI+Hv2MW3n4m3;0L$661h0lWu zTIBf7_r-$y#8e)$c-yi!wIjlM58ZT1Vj(w6_mN)^#sFeD;wZ`bp7bE+-Xso!APNh@p-3n#8sZ&RoS}zO$M>Sn;BaNEi#OzQv6ZgJdwEXC zqK8N-VU3M}{D8aG7n9x^3Zh2bS~I>VWqP#}s$ySg7j1p8t}*o;I?un`>cZaF2K=4F zE;rJaQQ0KP+8WA)UTOGahieBuXcPq9v$;f_F|LSt=6;j;4Z-#ln^uyaV+uq2Z5vYN zm6K{W0AO2))BWBbMFfAU!$6rKm@ett@-PM4Ioh}Ii8?y`_>1l2<=*7i-AO0;!`45V zZD~p@Ee+qPr;YlmwbP;0GiNo2I8^CHh`o*1G;*WQX~|5b-bhZSkqcvLtg=HWoIRLC z8D*==*+Pz{=4nS0#*vu5$wTgQrkk~MrNcO?(RF6i=Ld6B13X6$HLv;!*2L=ito0}E zqu1Oa=<=GQY7?gYZi%^(5kdGTe(KIagMw^!)aH|MN~m#hXpQfl!Q#ra@P@j`DNpFB z#j9|$-BA)!8I-MZ3i8owEaXHD(({czS$LS{g{Y|tEZD24jF7x_B^|up!Ax|L&zfuE zoauAz8e!F_tAkvZN7aZw$9&BW#A))c=zqRq((A->b;{KgEJhZ8`n*|TQczynkL%#rE?YI zm?MLyxs*j*%AQ?f@7i35w;Pgr%Eqg0`9fcN9}K?+$3N@LuT{x=Ncbr2?IeZz(q`tRr||?vV?MfK%-8J>reXqDA#<*nR4G^>5K}U@$6y+-tjw{{cMmn^ zZ{n@UHSQ;7GkuGgpBs1W+q^7mCP!S`m$JCe#U^t9zL@Pz=>g&ODbaQYT|0~~%xceM zEi<>K)V94lZ8?22THP(3Z)I=MeRV#pS7*b(g?a7{%^LHKR^8cWq7sSg&nG5MSM@C} z7+fNJRc)((voV8L;I>#B9cq6$Hq3hM*WzY2xBK-rTW2gyjfk)lSL*Hy@+9e*;g_ Bn*;y= literal 0 HcmV?d00001 diff --git a/ui/public/fonts/obscure.woff2 b/ui/public/fonts/obscure.woff2 new file mode 100644 index 0000000000000000000000000000000000000000..c2e583a761a1eb84723bf2f7cd0991d20a32c6dc GIT binary patch literal 888 zcmV-;1Bd)~Pew8T0RR9100Vdc4FCWD03N6S00STZ0RR9100000000000000000000 z0000#Mn+Uk92y=5U;u(j5eN#abe&KOfkprUHUcCAfldS<1%+z|fo2=j6;YH8Ndw|% zf^97Gq4&_5G#3U}I&O@=1kdw&edoT!11>y23!{SQ&b@>TdUL;vN(8{D-g8Y#jX|}K z`;>PwZzlRN7rtC13G#V>L=#FZc-+T$Ea1Vrz4-<$bxI{DQKHq1*9r(F=`eN~1Go_& z0Jod0`Ur4$k<@e#EkF=R4=4nUP6#@n08Ng|R|C{+bq1IVmXQY(7e&w)(DMCMBgJ@i z_WxB>Z4y~13nNnqpkZg$5(3n6N-04n-ytSCf&#|-K0qoP^q)w#6(-0cQ9#dyHQg|+ zm7irbXxSn92R+T(1Bfu8j0>r>vCfB>@_wAx{k-2_07RHj#)VYcSm#4bxzyIjT>ISj z`=6j?p!mK*=nSjR1HHg(3RV^(H(R3TC~o6+2w4x>ieT z%fUm=lrsZ*Mn^D{1`uIF85dG%W1SB%<^4FX`+2{=0EjT5j0>r>vCfB> Oa;dG4x%Rp5_X7Zc$%2dk literal 0 HcmV?d00001 diff --git a/vault/ui.go b/vault/ui.go index 952137da3508..c36a247af304 100644 --- a/vault/ui.go +++ b/vault/ui.go @@ -32,7 +32,7 @@ type UIConfig struct { // NewUIConfig creates a new UI config func NewUIConfig(enabled bool, physicalStorage physical.Backend, barrierStorage logical.Storage) *UIConfig { defaultHeaders := http.Header{} - defaultHeaders.Set("Content-Security-Policy", "default-src 'none'; connect-src 'self'; img-src 'self' data:; script-src 'self'; style-src 'unsafe-inline' 'self'; form-action 'none'; frame-ancestors 'none'") + defaultHeaders.Set("Content-Security-Policy", "default-src 'none'; connect-src 'self'; img-src 'self' data:; script-src 'self'; style-src 'unsafe-inline' 'self'; form-action 'none'; frame-ancestors 'none'; font-src 'self'") defaultHeaders.Set("Service-Worker-Allowed", "/") return &UIConfig{ From 41f8fdba8e05c4c8f3b38107bfe1923c06de26f4 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 5 Apr 2021 13:20:59 -0600 Subject: [PATCH 02/37] clean up logic --- .../components/secret-edit-display.hbs | 1 + ui/lib/core/addon/components/masked-input.js | 24 ++++--------------- .../templates/components/masked-input.hbs | 13 +++++----- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/ui/app/templates/components/secret-edit-display.hbs b/ui/app/templates/components/secret-edit-display.hbs index 7d5b6481d124..c0a02d477694 100644 --- a/ui/app/templates/components/secret-edit-display.hbs +++ b/ui/app/templates/components/secret-edit-display.hbs @@ -69,6 +69,7 @@ @onKeyDown={{@editActions.handleKeyDown}} @onChange={{@editActions.handleChange}} @value={{secret.value}} + @maskWhileTyping={{true}} data-test-secret-value="true" /> diff --git a/ui/lib/core/addon/components/masked-input.js b/ui/lib/core/addon/components/masked-input.js index a0d26b3a0add..f511aab07340 100644 --- a/ui/lib/core/addon/components/masked-input.js +++ b/ui/lib/core/addon/components/masked-input.js @@ -1,5 +1,4 @@ import Component from '@ember/component'; -import { computed } from '@ember/object'; import autosize from 'autosize'; import layout from '../templates/components/masked-input'; @@ -20,6 +19,7 @@ import layout from '../templates/components/masked-input'; * @param [allowCopy=null] {bool} - Whether or not the input should render with a copy button. * @param [displayOnly=false] {bool} - Whether or not to display the value as a display only `pre` element or as an input. * @param [onChange=Function.prototype] {Function|action} - A function to call when the value of the input changes. + * @param [maskWhileTyping=false] {bool} - Whether or not to mask the value while typing by using the custom obscure font. * * */ @@ -28,6 +28,7 @@ export default Component.extend({ layout, value: null, placeholder: 'value', + maskWhileTyping: false, didInsertElement() { this._super(...arguments); autosize(this.element.querySelector('textarea')); @@ -40,30 +41,13 @@ export default Component.extend({ this._super(...arguments); autosize.destroy(this.element.querySelector('textarea')); }, - shouldObscure: computed('isMasked', 'isFocused', 'value', function() { - if (this.value === '') { - return false; - } - if (this.isFocused === true) { - return false; - } - return this.isMasked; - }), - displayValue: computed('shouldObscure', 'value', function() { - if (this.shouldObscure) { - return '■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■'; - } else { - return this.value; - } - }), - isMasked: true, - isFocused: false, displayOnly: false, + showValue: false, onKeyDown() {}, onChange() {}, actions: { toggleMask() { - this.toggleProperty('isMasked'); + this.toggleProperty('showValue'); }, updateValue(e) { let value = e.target.value; diff --git a/ui/lib/core/addon/templates/components/masked-input.hbs b/ui/lib/core/addon/templates/components/masked-input.hbs index b840efe625de..2c319514d776 100644 --- a/ui/lib/core/addon/templates/components/masked-input.hbs +++ b/ui/lib/core/addon/templates/components/masked-input.hbs @@ -1,22 +1,21 @@ -
{{#if displayOnly}} -
{{displayValue}}
+
{{value}}
{{else if maskWhileTyping}} {{else}} + {{!-- ARG todo for text area as well --}} @@ -54,7 +54,7 @@ {{#if key.fileName}} {{key.fileName}} {{else}} - Choose a file… + Choose a file…meep {{/if}} {{#if key.fileName}} diff --git a/ui/app/templates/components/secret-edit.hbs b/ui/app/templates/components/secret-edit.hbs index cefe55f43818..c53e334affc8 100644 --- a/ui/app/templates/components/secret-edit.hbs +++ b/ui/app/templates/components/secret-edit.hbs @@ -147,6 +147,7 @@ {{#each modelForData.secretKeyAndValue as |secret|}} - + {{/each}} {{/if}} diff --git a/ui/app/templates/vault/cluster/init.hbs b/ui/app/templates/vault/cluster/init.hbs index 49d2024e4985..02efea24a7ed 100644 --- a/ui/app/templates/vault/cluster/init.hbs +++ b/ui/app/templates/vault/cluster/init.hbs @@ -49,6 +49,7 @@ @@ -66,6 +67,7 @@ diff --git a/ui/lib/core/addon/components/masked-input.js b/ui/lib/core/addon/components/masked-input.js index dc12cf38141d..366051acc2f3 100644 --- a/ui/lib/core/addon/components/masked-input.js +++ b/ui/lib/core/addon/components/masked-input.js @@ -22,6 +22,7 @@ import layout from '../templates/components/masked-input'; * @param [maskByDefault=false] {bool} - Relevant only when using DisplayOnly value. If true this by default masks the value. * @param [onChange=Function.prototype] {Function|action} - A function to call when the value of the input changes. * @param [maskWhileTyping=false] {bool} - Whether or not to mask the value while typing by using the custom obscure font. + * @param [isCertificate=false] {bool} - If certificate display the label and icons differently. * * */ diff --git a/ui/lib/core/addon/templates/components/info-table-row.hbs b/ui/lib/core/addon/templates/components/info-table-row.hbs index f2041d893af0..ccd102b684ed 100644 --- a/ui/lib/core/addon/templates/components/info-table-row.hbs +++ b/ui/lib/core/addon/templates/components/info-table-row.hbs @@ -58,7 +58,16 @@ {{else}} - {{value}} + {{#if (eq label "Certificate")}} + + {{else}} + {{value}} + {{/if}} {{/if}} {{/if}} {{/if}} From f83052fda71b04dff26df63408bf631a3b362e6e Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 9 Apr 2021 09:32:52 -0600 Subject: [PATCH 05/37] work on certificates --- ui/app/templates/components/config-pki-ca.hbs | 28 ++++++++++++++++++- .../components/generate-credentials.hbs | 3 ++ ui/lib/core/addon/helpers/date-format.js | 3 ++ .../templates/components/info-table-row.hbs | 11 +------- .../templates/components/masked-input.hbs | 3 +- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/ui/app/templates/components/config-pki-ca.hbs b/ui/app/templates/components/config-pki-ca.hbs index 9170e0e2502a..6b96ca894a4d 100644 --- a/ui/app/templates/components/config-pki-ca.hbs +++ b/ui/app/templates/components/config-pki-ca.hbs @@ -9,7 +9,33 @@ {{#if (or model.certificate model.csr)}} {{#each model.attrs as |attr|}} - {{info-table-row data-test-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(get model attr.name)}} + {{#if (or + (eq attr.name "csr") + (eq attr.name "certificate") + (eq attr.name "issuingCa") + (eq attr.name "caChain") + (eq attr.name "privateKey") + )}} + + + + {{else if (eq attr.name "expiration")}} + {{info-table-row + data-test-table-row + label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) + value=(date-format (get model attr.name) 'MMM dd, yyyy hh:mm:ss a') + }} + {{else}} + {{info-table-row + data-test-table-row + label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) + value=(get model attr.name) + }} + {{/if}} {{/each}}
diff --git a/ui/app/templates/components/generate-credentials.hbs b/ui/app/templates/components/generate-credentials.hbs index f96faf316b85..4a02bbc082ca 100644 --- a/ui/app/templates/components/generate-credentials.hbs +++ b/ui/app/templates/components/generate-credentials.hbs @@ -49,6 +49,9 @@ (eq attr.name "secretKey") (eq attr.name "securityToken") (eq attr.name "privateKey") + (eq attr.name "certificate") + (eq attr.name "issuingCa") + (eq attr.name "caChain") )}} {{else}} - {{#if (eq label "Certificate")}} - - {{else}} - {{value}} - {{/if}} + {{value}} {{/if}} {{/if}} {{/if}} diff --git a/ui/lib/core/addon/templates/components/masked-input.hbs b/ui/lib/core/addon/templates/components/masked-input.hbs index 61aa1d65b0cb..3a6a63de2b09 100644 --- a/ui/lib/core/addon/templates/components/masked-input.hbs +++ b/ui/lib/core/addon/templates/components/masked-input.hbs @@ -1,7 +1,7 @@
{{#if displayOnly}} -
{{value}}
+
{{unless showValue (truncate value 20) value}}
{{else if maskWhileTyping}} {{else}} - {{!-- ARG todo for text area as well --}} +

{{textareaHelpText}} diff --git a/ui/lib/core/addon/templates/components/masked-input.hbs b/ui/lib/core/addon/templates/components/masked-input.hbs index 3a6a63de2b09..d6e260dbcc91 100644 --- a/ui/lib/core/addon/templates/components/masked-input.hbs +++ b/ui/lib/core/addon/templates/components/masked-input.hbs @@ -27,7 +27,7 @@ {{/if}} From 757125eca478d547e93907943c301ed1b6c0bbb9 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 9 Apr 2021 11:18:13 -0600 Subject: [PATCH 07/37] fix global styling --- ui/app/styles/components/text-file.scss | 12 +++++++----- ui/app/templates/components/text-file.hbs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/app/styles/components/text-file.scss b/ui/app/styles/components/text-file.scss index 137ae400fd1d..acb126f630ee 100644 --- a/ui/app/styles/components/text-file.scss +++ b/ui/app/styles/components/text-file.scss @@ -1,8 +1,10 @@ -.has-icon-right { - display: flex; - width: 97%; +.text-file { + .has-icon-right { + display: flex; + width: 97%; - .textarea { - line-height: inherit; + .textarea { + line-height: inherit; + } } } diff --git a/ui/app/templates/components/text-file.hbs b/ui/app/templates/components/text-file.hbs index c04f0c85da8b..441ada68a8ad 100644 --- a/ui/app/templates/components/text-file.hbs +++ b/ui/app/templates/components/text-file.hbs @@ -34,7 +34,7 @@

{{/unless}} -
+
{{#if file.enterAsText}}
-

- {{textareaHelpText}} + {{this.textareaHelpText}}

{{else}}

- {{fileHelpText}} + {{this.fileHelpText}}

{{/if}}
diff --git a/ui/app/templates/vault/cluster/policies/create.hbs b/ui/app/templates/vault/cluster/policies/create.hbs index b7ea167daaca..a179abd0c06e 100644 --- a/ui/app/templates/vault/cluster/policies/create.hbs +++ b/ui/app/templates/vault/cluster/policies/create.hbs @@ -46,7 +46,12 @@
{{#if showFileUpload}} - + {{else}} Date: Tue, 13 Apr 2021 11:33:39 -0600 Subject: [PATCH 13/37] not doing awesome over here --- ui/app/styles/components/masked-input.scss | 10 ++++---- ui/app/styles/core/forms.scss | 4 +++- ui/lib/core/addon/components/masked-input.js | 23 +++++++++++++------ .../templates/components/masked-input.hbs | 22 ++++++++++++++---- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/ui/app/styles/components/masked-input.scss b/ui/app/styles/components/masked-input.scss index 8dc30cbb2e0d..f471920c8d91 100644 --- a/ui/app/styles/components/masked-input.scss +++ b/ui/app/styles/components/masked-input.scss @@ -1,10 +1,10 @@ // ARG chance I could remove because of form style .masked-font { - font-family: obscure; - font-size: $size-medium; - letter-spacing: 2px; - line-height: 2.5; - color: $ui-gray-300; + // font-family: obscure; + // font-size: $size-medium; + // letter-spacing: 2px; + // line-height: 2.5; + color: $ui-gray-300; // because on form css this color gets overridden in the CSS } .masked-input { diff --git a/ui/app/styles/core/forms.scss b/ui/app/styles/core/forms.scss index 898ff593ec9f..285cc3247a2f 100644 --- a/ui/app/styles/core/forms.scss +++ b/ui/app/styles/core/forms.scss @@ -15,8 +15,10 @@ label { font-family: obscure; font-size: $size-medium; letter-spacing: 2px; - line-height: 2.5; color: $ui-gray-300; + + // ARG TODO for certificates only. + // line-height: 2.5; } .label { diff --git a/ui/lib/core/addon/components/masked-input.js b/ui/lib/core/addon/components/masked-input.js index 5820a0914db6..ff34651f55cb 100644 --- a/ui/lib/core/addon/components/masked-input.js +++ b/ui/lib/core/addon/components/masked-input.js @@ -28,16 +28,24 @@ import layout from '../templates/components/masked-input'; */ class MaskedInput extends Component { layout; - - placeholder = 'value'; - displayOnly = false; - onKeyDown() {} - onChange() {} - @tracked showValue = false; + @tracked value = null; + onKeyDown() {} + onChange() {} + + get defaultDisplayOnly() { + return this.args.displayOnly || false; + } + + get defaultPlaceholder() { + if (this.args.placeholder) { + this.showValue = true; + } + return this.args.placeholder || 'value'; + } @action toggleMask() { @@ -47,8 +55,9 @@ class MaskedInput extends Component { updateValue(e) { e.preventDefault(); let value = e.target.value; - console.log(value, 'value'); this.value = value; + console.log('value in masked input', value); + console.log(this.args.onChange()); this.onChange(value); } } diff --git a/ui/lib/core/addon/templates/components/masked-input.hbs b/ui/lib/core/addon/templates/components/masked-input.hbs index cbe4a82b83cd..3c25c95fe4d5 100644 --- a/ui/lib/core/addon/templates/components/masked-input.hbs +++ b/ui/lib/core/addon/templates/components/masked-input.hbs @@ -1,22 +1,34 @@ +
{{#if @displayOnly}}
{{unless this.showValue (truncate @value 20) @value}}
- {{else}} + {{else if @inputField}} + {{else}} + From 44db29b47fbcb2e7a060f95ac41dd9b1b3508e25 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 16 Apr 2021 10:18:26 -0600 Subject: [PATCH 31/37] changelog --- changelog/11284.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/11284.txt diff --git a/changelog/11284.txt b/changelog/11284.txt new file mode 100644 index 000000000000..8c0332a3b008 --- /dev/null +++ b/changelog/11284.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Obscure secret values on input and displayOnly fields like certificates. +``` \ No newline at end of file From 7190c08d1fc895fbe8075e8fc2bb20c4ea984822 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Tue, 20 Apr 2021 10:19:46 -0600 Subject: [PATCH 32/37] cover other certificate view --- ui/app/templates/components/config-pki-ca.hbs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ui/app/templates/components/config-pki-ca.hbs b/ui/app/templates/components/config-pki-ca.hbs index 5c037200e5a1..2d84c1d63b44 100644 --- a/ui/app/templates/components/config-pki-ca.hbs +++ b/ui/app/templates/components/config-pki-ca.hbs @@ -95,7 +95,22 @@ data-test-warning /> {{#each model.attrs as |attr|}} - {{info-table-row data-test-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(get model attr.name)}} + {{#if (or + (eq attr.name "csr") + (eq attr.name "certificate") + (eq attr.name "issuingCa") + (eq attr.name "caChain") + (eq attr.name "privateKey") + )}} + + + + {{else}} + {{info-table-row data-test-table-row label=(capitalize (or attr.options.label (humanize (dasherize attr.name)))) value=(get model attr.name)}} + {{/if}} {{/each}}
From b9e4390042c54e1480d03458720d822d8ae81a34 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Tue, 20 Apr 2021 10:32:22 -0600 Subject: [PATCH 33/37] add allowCopy --- ui/app/templates/components/config-pki-ca.hbs | 2 ++ ui/app/templates/components/generate-credentials.hbs | 1 + 2 files changed, 3 insertions(+) diff --git a/ui/app/templates/components/config-pki-ca.hbs b/ui/app/templates/components/config-pki-ca.hbs index 2d84c1d63b44..49b15c2be862 100644 --- a/ui/app/templates/components/config-pki-ca.hbs +++ b/ui/app/templates/components/config-pki-ca.hbs @@ -20,6 +20,7 @@ {{else if (eq attr.name "expiration")}} @@ -106,6 +107,7 @@ {{else}} diff --git a/ui/app/templates/components/generate-credentials.hbs b/ui/app/templates/components/generate-credentials.hbs index 21755b6507e4..a618a3880f61 100644 --- a/ui/app/templates/components/generate-credentials.hbs +++ b/ui/app/templates/components/generate-credentials.hbs @@ -58,6 +58,7 @@ @value={{get model attr.name}} @name={{attr.name}} @displayOnly={{true}} + @allowCopy={{true}} /> {{else}} From e52fdb1b69ef56e26ed1a9963b0499c4af0e43cf Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 21 Apr 2021 09:43:47 -0600 Subject: [PATCH 34/37] address some pr styling comments --- ui/app/components/text-file.js | 2 +- ui/app/models/pki-ca-certificate.js | 1 + ui/app/models/pki-certificate.js | 10 ++++++++-- ui/app/styles/components/masked-input.scss | 1 - ui/app/styles/components/text-file.scss | 4 ++++ ui/app/templates/components/config-pki-ca.hbs | 16 ++-------------- ui/app/templates/components/pki-cert-show.hbs | 1 + 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/ui/app/components/text-file.js b/ui/app/components/text-file.js index 0e9e5d9ecea0..0f82d11cb76e 100644 --- a/ui/app/components/text-file.js +++ b/ui/app/components/text-file.js @@ -23,7 +23,7 @@ import { guidFor } from '@ember/object/internals'; * { * value: 'file contents here', * fileName: 'nameOfFile.txt', - * enterAsText: bool + * enterAsText: boolean ability to enter as text * } * @param [onChange=Function.prototype] {Function|action} - A function to call when the value of the input changes. * @param [label=null] {string} - Text to use as the label for the file input. If null, a default will be rendered. diff --git a/ui/app/models/pki-ca-certificate.js b/ui/app/models/pki-ca-certificate.js index 08ebd372be4b..255df6f02c2c 100644 --- a/ui/app/models/pki-ca-certificate.js +++ b/ui/app/models/pki-ca-certificate.js @@ -143,6 +143,7 @@ export default Certificate.extend({ csr: attr('string', { editType: 'textarea', label: 'CSR', + masked: true, }), expiration: attr(), diff --git a/ui/app/models/pki-certificate.js b/ui/app/models/pki-certificate.js index 73bd6895e5b4..9a5a481cf16a 100644 --- a/ui/app/models/pki-certificate.js +++ b/ui/app/models/pki-certificate.js @@ -63,14 +63,20 @@ export default Model.extend({ defaultValue: false, }), - certificate: attr('string'), + certificate: attr('string', { + masked: true, + }), issuingCa: attr('string', { label: 'Issuing CA', + masked: true, }), caChain: attr('string', { label: 'CA chain', + masked: true, + }), + privateKey: attr('string', { + masked: true, }), - privateKey: attr('string'), privateKeyType: attr('string'), serialNumber: attr('string'), diff --git a/ui/app/styles/components/masked-input.scss b/ui/app/styles/components/masked-input.scss index 872289c15d1c..65f03e0cba32 100644 --- a/ui/app/styles/components/masked-input.scss +++ b/ui/app/styles/components/masked-input.scss @@ -49,7 +49,6 @@ border-left: 0; color: $grey; box-shadow: 0 3px 1px 0px rgba(10, 10, 10, 0.12); - display: flex; } .button.copy-button { diff --git a/ui/app/styles/components/text-file.scss b/ui/app/styles/components/text-file.scss index acb126f630ee..f7dd0f8f7a3e 100644 --- a/ui/app/styles/components/text-file.scss +++ b/ui/app/styles/components/text-file.scss @@ -7,4 +7,8 @@ line-height: inherit; } } + .button.masked-input-toggle, + .button.copy-button { + display: flex; + } } diff --git a/ui/app/templates/components/config-pki-ca.hbs b/ui/app/templates/components/config-pki-ca.hbs index 49b15c2be862..a7b412c71c31 100644 --- a/ui/app/templates/components/config-pki-ca.hbs +++ b/ui/app/templates/components/config-pki-ca.hbs @@ -9,13 +9,7 @@ {{#if (or model.certificate model.csr)}} {{#each model.attrs as |attr|}} - {{#if (or - (eq attr.name "csr") - (eq attr.name "certificate") - (eq attr.name "issuingCa") - (eq attr.name "caChain") - (eq attr.name "privateKey") - )}} + {{#if attr.options.masked}} {{#each model.attrs as |attr|}} - {{#if (or - (eq attr.name "csr") - (eq attr.name "certificate") - (eq attr.name "issuingCa") - (eq attr.name "caChain") - (eq attr.name "privateKey") - )}} + {{#if attr.options.masked}} {{else}} From ccd028e667bf69ec95defa036af279aa9ad6cd04 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 21 Apr 2021 10:12:41 -0600 Subject: [PATCH 35/37] improve test coverage --- ui/tests/acceptance/secrets/backend/pki/cert-test.js | 2 ++ ui/tests/acceptance/wrapped-token-test.js | 2 +- ui/tests/integration/components/masked-input-test.js | 10 +++++++++- ui/tests/integration/helpers/date-format-test.js | 8 ++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ui/tests/acceptance/secrets/backend/pki/cert-test.js b/ui/tests/acceptance/secrets/backend/pki/cert-test.js index 7a444ad5e06c..1c6892c0e775 100644 --- a/ui/tests/acceptance/secrets/backend/pki/cert-test.js +++ b/ui/tests/acceptance/secrets/backend/pki/cert-test.js @@ -55,6 +55,8 @@ elRplAzrMF4= await settled(); await generatePage.issueCert('foo'); await settled(); + let countMaskedFonts = document.querySelectorAll('.masked-font').length; + assert.equal(countMaskedFonts, 3); // certificate, issuing ca, and private key let firstUnMaskButton = document.querySelectorAll('.masked-input-toggle')[0]; await click(firstUnMaskButton); assert.dom('.masked-value').hasTextContaining('-----BEGIN CERTIFICATE-----'); diff --git a/ui/tests/acceptance/wrapped-token-test.js b/ui/tests/acceptance/wrapped-token-test.js index 565ffd26d23d..6f3fa390f642 100644 --- a/ui/tests/acceptance/wrapped-token-test.js +++ b/ui/tests/acceptance/wrapped-token-test.js @@ -28,7 +28,7 @@ const setupWrapping = async () => { module('Acceptance | wrapped_token query param functionality', function(hooks) { setupApplicationTest(hooks); - test('it authenticates you if the query param is present meep', async function(assert) { + test('it authenticates you if the query param is present', async function(assert) { let token = await setupWrapping(); await auth.visit({ wrapped_token: token }); await settled(); diff --git a/ui/tests/integration/components/masked-input-test.js b/ui/tests/integration/components/masked-input-test.js index 7dcd63b39274..66c815f30ddb 100644 --- a/ui/tests/integration/components/masked-input-test.js +++ b/ui/tests/integration/components/masked-input-test.js @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { render, focus } from '@ember/test-helpers'; import { create } from 'ember-cli-page-object'; import hbs from 'htmlbars-inline-precompile'; import maskedInput from 'vault/tests/pages/components/masked-input'; @@ -80,4 +80,12 @@ module('Integration | Component | masked input', function(hooks) { let unMaskedValue = document.querySelector('.masked-value').innerText; assert.equal(unMaskedValue.length, this.value.length); }); + + test('it does not unmask text on focus', async function(assert) { + this.set('value', '123456789-123456789-123456789'); + await render(hbs`{{masked-input value=value}}`); + assert.dom('.masked-value').hasClass('masked-font'); + await focus('.masked-value'); + assert.dom('.masked-value').hasClass('masked-font'); + }); }); diff --git a/ui/tests/integration/helpers/date-format-test.js b/ui/tests/integration/helpers/date-format-test.js index a41db85f975d..5349686d68c7 100644 --- a/ui/tests/integration/helpers/date-format-test.js +++ b/ui/tests/integration/helpers/date-format-test.js @@ -34,4 +34,12 @@ module('Integration | Helper | date-format', function(hooks) { .dom('[data-test-date-format]') .includesText(todayString, 'it renders the a date if passed in as a string'); }); + + test('it supports ten digit dates', async function(assert) { + let tenDigitDate = 1621785298; + this.set('tenDigitDate', tenDigitDate); + + await render(hbs`

Date: {{date-format tenDigitDate "MM/dd/yyyy"}}

`); + assert.dom('[data-test-date-format]').includesText('05/23/2021'); + }); }); From fb38f21367d152bd3f4933858f4ce22ae39180a0 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 21 Apr 2021 16:50:14 -0600 Subject: [PATCH 36/37] fix some issues --- .../components/generate-credentials.hbs | 4 +-- .../partials/secret-backend-settings/ssh.hbs | 11 ++++++-- ui/lib/kmip/addon/templates/configuration.hbs | 11 +++++--- .../kmip/addon/templates/credentials/show.hbs | 28 +++++++++++++------ .../pki/section-cert-test.js | 3 +- 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/ui/app/templates/components/generate-credentials.hbs b/ui/app/templates/components/generate-credentials.hbs index a618a3880f61..3d0f7111bcef 100644 --- a/ui/app/templates/components/generate-credentials.hbs +++ b/ui/app/templates/components/generate-credentials.hbs @@ -49,9 +49,7 @@ (eq attr.name "secretKey") (eq attr.name "securityToken") (eq attr.name "privateKey") - (eq attr.name "certificate") - (eq attr.name "issuingCa") - (eq attr.name "caChain") + attr.options.masked )}}
-