-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The API now features a rekeying endpoint for re-encrypting the Vault credentials with a new master password. The CLI now features a `shield rekey` command that facilitates calling the API to do the rekeying. The Web UI now features a `#!/admin/rekey-master` page for effecting a rekey operation from the front-end. As an added bonus, the UI source code has been modified to better handle folding in vscode, if you're into that sort of thing.
- Loading branch information
Showing
7 changed files
with
3,497 additions
and
3,275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package access | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/starkandwayne/goutils/ansi" | ||
"github.com/starkandwayne/shield/api" | ||
"github.com/starkandwayne/shield/cmd/shield/commands" | ||
"github.com/starkandwayne/shield/cmd/shield/commands/internal" | ||
"github.com/starkandwayne/shield/cmd/shield/log" | ||
"golang.org/x/crypto/ssh/terminal" | ||
) | ||
|
||
//Rekey - Rekeys the encryption database keys | ||
var Rekey = &commands.Command{ | ||
Summary: "Rekey the encryption database keys", | ||
Help: &commands.HelpInfo{}, | ||
RunFn: cliRekey, | ||
Group: commands.AccessGroup, | ||
} | ||
|
||
func cliRekey(opts *commands.Options, args ...string) error { | ||
log.DEBUG("running 'rekey' command") | ||
|
||
internal.Require(len(args) == 0, "USAGE: shield rekey") | ||
|
||
curmaster := SecurePrompt("%s @Y{[hidden]:} ", "current_master_password") | ||
|
||
newmaster := "" | ||
for { | ||
a := SecurePrompt("%s @Y{[hidden]:} ", "master_password") | ||
b := SecurePrompt("%s @C{[confirm]:} ", "master_password") | ||
|
||
if a != "" && (a == b || !terminal.IsTerminal(int(os.Stdin.Fd()))) { | ||
ansi.Fprintf(os.Stderr, "\n") | ||
newmaster = a | ||
break | ||
} | ||
ansi.Fprintf(os.Stderr, "\n@Y{oops, passwords do not match: try again }(Ctrl-C to cancel)\n\n") | ||
} | ||
if err := api.Rekey(curmaster, newmaster); err != nil { | ||
return err | ||
} | ||
|
||
commands.OK("Successfully rekeyed the encryption database") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.