Encrypt tokens on the way out and decrypt on the way in (#302)

* Encrypt tokens on the way out and decrypt on the way in

This isn't a security feature related to tokens specifically; it's so
that we can discard cryptographically bad tokens before we ever hit the
DB. This way we can't pass through a DDoS to the database due to
fetching obviously invalid token values.

I'm using base58 to encode the resulting value as there aren't great
base62 options, and allowing base64 / and + values can hamper usability
by creating copying/highlighting breaks.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-25 00:20:50 -04:00
1 parent 647d5502b5
commit 74544f6324
15 files changed
+196 -49

No files matched your search

@@ -112,7 +112,7 @@ func (c *PasswordCommand) Run(args []string) int {
c.flagPassword = strings.TrimSpace(value)
}
client, err := c.Client(base.WithNoTokenScope())
client, err := c.Client(base.WithNoTokenScope(), base.WithNoTokenValue())
if err != nil {
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
return 2