@@ -71,17 +71,18 @@ func (*RootCmd) dbcryptRotateCmd() *clibase.Cmd {
71
71
return xerrors .Errorf ("create ciphers: %w" , err )
72
72
}
73
73
74
- newDigest := ciphers [0 ].HexDigest ()
75
- oldDigests := make ([]string , 0 , len (ciphers )- 1 )
76
- for _ , c := range ciphers [1 :] {
77
- oldDigests = append (oldDigests , c .HexDigest ())
74
+ var act string
75
+ switch len (flags .Old ) {
76
+ case 0 :
77
+ act = "Data will be encrypted with the new key."
78
+ default :
79
+ act = "Data will be decrypted with all available keys and re-encrypted with new key."
78
80
}
79
- if len (oldDigests ) == 0 {
80
- oldDigests = append (oldDigests , "none" )
81
- }
82
- msg := fmt .Sprintf (`Rotate external token encryptions keys?\n- New key: %s\n- Old keys: %s` ,
83
- newDigest ,
84
- strings .Join (oldDigests , ", " ),
81
+
82
+ msg := fmt .Sprintf ("%s\n \n - New key: %s\n - Old keys: %s\n \n Rotate external token encryption keys?\n " ,
83
+ act ,
84
+ flags .New ,
85
+ strings .Join (flags .Old , ", " ),
85
86
)
86
87
if _ , err := cliui .Prompt (inv , cliui.PromptOptions {Text : msg , IsConfirm : true }); err != nil {
87
88
return err
@@ -179,9 +180,13 @@ func (*RootCmd) dbcryptDeleteCmd() *clibase.Cmd {
179
180
if err := flags .valid (); err != nil {
180
181
return err
181
182
}
183
+ msg := `All encrypted data will be deleted from the database:
184
+ - Encrypted user OAuth access and refresh tokens
185
+ - Encrypted user Git authentication access and refresh tokens
182
186
187
+ Are you sure you want to continue?`
183
188
if _ , err := cliui .Prompt (inv , cliui.PromptOptions {
184
- Text : "This will delete all encrypted data from the database. Are you sure you want to continue?" ,
189
+ Text : msg ,
185
190
IsConfirm : true ,
186
191
}); err != nil {
187
192
return err
@@ -238,6 +243,10 @@ func (f *rotateFlags) attach(opts *clibase.OptionSet) {
238
243
}
239
244
240
245
func (f * rotateFlags ) valid () error {
246
+ if f .PostgresURL == "" {
247
+ return xerrors .Errorf ("no database configured" )
248
+ }
249
+
241
250
if f .New == "" {
242
251
return xerrors .Errorf ("no new key provided" )
243
252
}
@@ -289,6 +298,10 @@ func (f *decryptFlags) attach(opts *clibase.OptionSet) {
289
298
}
290
299
291
300
func (f * decryptFlags ) valid () error {
301
+ if f .PostgresURL == "" {
302
+ return xerrors .Errorf ("no database configured" )
303
+ }
304
+
292
305
if len (f .Keys ) == 0 {
293
306
return xerrors .Errorf ("no keys provided" )
294
307
}
0 commit comments