Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui/provide otp #8630

Merged
merged 4 commits into from Mar 31, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions ui/app/templates/components/shamir-flow.hbs
Expand Up @@ -4,11 +4,7 @@
<HoverCopyButton @copyValue={{encoded_token}} />
<div class="message-body">
<h4 class="title is-7 is-marginless">
{{#if otp}}
Encoded Operation Token
{{else}}
Encrypted Operation Token
{{/if}}
Encoded Operation Token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference here between encoded and encrypted? Is it important to keep the word encrypted on the refresh situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this question! i wondered the same thing. all of the examples in this previous commit [1][2] made it sound like the resulting value is actually encoded -- i couldn't figure out why we ever referred to it as encrypted. @meirish do you know?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think originally this was meant to denote the difference between the PGP encrypted, and the OTP which does an XOR (https://en.wikipedia.org/wiki/XOR_cipher#Use_and_security) to decode the token, but I don't think it's important to keep. Looking at the wikipedia page, OTP stands for "one time pad" not "one time password" which I didn't realize when building this the first time.

</h4>
<code class="is-word-break">{{encoded_token}}</code>
</div>
Expand All @@ -23,20 +19,19 @@
<code class="is-word-break">{{otp}}</code>
</div>
</div>
{{/if}}
<div class="message is-list has-copy-button" tabindex="-1">
{{#let
(concat 'vault operator generate-root -dr-token -otp="' otp '" -decode="' encoded_token '"')
as |cmd|}}
{{#with (if otp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the documentation on these template helpers, but I'm unclear why it's better to use "with" here instead of "let". This is more of a clarity question as I'm not super familiar with these template helpers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an excellent question! your instincts to use let were spot on, aslet is increasingly preferred over with. the difference is that with allows you to only render a block if the first positional param is true. that's useful in this situation, but we can easily accomplish the same outcome by using let and if. the example in this RFC which calls for deprecating with explains this really well:

https://github.com/emberjs/rfcs/blob/master/text/0445-deprecate-with.md#motivation

(concat 'vault operator generate-root -otp="' otp '" -decode="' encoded_token '"') (concat 'vault operator generate-root -otp="<enter your otp here>" -decode="' encoded_token '"') ) as |cmd|}}
<HoverCopyButton @copyValue={{cmd}} />
<div class="message-body">
<h4 class="title is-7 is-marginless">
DR Operation Token Command
</h4>
<code class="is-word-break">{{cmd}}</code>
</div>
{{/let}}
{{/with}}
</div>
{{/if}}
</div>
<div class="box is-marginless is-shadowless">
<button type="button" class="button" {{action 'reset'}}>
Expand Down Expand Up @@ -131,6 +126,20 @@
</div>
{{/if}}
<div class="box is-shadowless is-marginless no-padding-top is-fullwidth" data-test-form-text>
{{#if otp}}
<p>
<AlertBanner @type="info" @message="Below is the generated OTP. This will be used to encode the generated Operation Token. Make sure to save this, as you will need it later to decode the Operation Token." />
</p>
<div class="message is-list has-copy-button" tabindex="-1">
<HoverCopyButton @copyValue={{otp}} />
<div class="message-body">
<h4 class="title is-7 is-marginless">
One Time Password (otp)
</h4>
<code class="is-word-break">{{otp}}</code>
</div>
</div>
{{/if}}
{{#if (has-block)}}
{{yield}}
{{else if formText}}
Expand Down