feat: let administrators view and copy encrypted integration credentials

This commit is contained in:
2026-09-27 13:48:26 +08:00
parent 5555a7b342
commit d54bdd9847
38 changed files with 905 additions and 71 deletions

View File

@@ -13,6 +13,7 @@ import (
"time"
"git.yuntuo.hk/k2safe/orbit/internal/config"
"git.yuntuo.hk/k2safe/orbit/internal/credentialvault"
"git.yuntuo.hk/k2safe/orbit/internal/storage/mysql"
core "git.yuntuo.hk/k2safe/orbit/model"
)
@@ -112,7 +113,11 @@ func runCredentialChange(args []string, action string) error {
if err := writePrivateOperation(output, op); err != nil {
return err
}
receipt, err := mysql.ApplyCredentialOperation(ctx, db, op)
vault, err := credentialvault.LoadFile(os.Getenv("ORBIT_CREDENTIAL_KEY_FILE"))
if err != nil {
return err
}
receipt, err := mysql.ApplyCredentialOperation(ctx, db, op, vault)
if err != nil {
return errors.New("credential operation was not confirmed; the private operation file was retained for reconciliation")
}
@@ -138,7 +143,11 @@ func runCredentialApply(args []string) error {
return err
}
defer closeDB()
receipt, err := mysql.ApplyCredentialOperation(ctx, db, op)
vault, err := credentialvault.LoadFile(os.Getenv("ORBIT_CREDENTIAL_KEY_FILE"))
if err != nil {
return err
}
receipt, err := mysql.ApplyCredentialOperation(ctx, db, op, vault)
if err != nil {
return errors.New("credential operation was not confirmed; retry with the same private operation file")
}