-
Notifications
You must be signed in to change notification settings - Fork 16
/
wal.go
49 lines (38 loc) · 1.01 KB
/
wal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package azureauth
import (
"context"
"fmt"
"time"
"github.com/hashicorp/vault/sdk/logical"
)
const (
walRotateRootCreds = "rotateRootCreds"
)
func (b *azureAuthBackend) walRollback(ctx context.Context, req *logical.Request, kind string, data interface{}) error {
switch kind {
case walRotateRootCreds:
return b.rollbackRootWAL(ctx, req, data)
default:
return fmt.Errorf("unknown rollback type %q", kind)
}
}
type walRotateRoot struct{}
func (b *azureAuthBackend) rollbackRootWAL(ctx context.Context, req *logical.Request, data interface{}) error {
b.Logger().Debug("rolling back config")
config, err := b.config(ctx, req.Storage)
if err != nil {
return err
}
config.NewClientSecret = ""
config.NewClientSecretCreated = time.Time{}
config.NewClientSecretExpirationDate = time.Time{}
config.NewClientSecretKeyID = ""
err = b.saveConfig(ctx, config, req.Storage)
if err != nil {
return err
}
b.updatePassword = false
return nil
}