Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rotation Manager stubs for OSS #26360

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/credential/ldap/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func Backend() *backend {

AuthRenew: b.pathLoginRenew,
BackendType: logical.TypeCredential,
RotatePassword: func(ctx context.Context, req *logical.Request) error {
RotateCredential: func(ctx context.Context, req *logical.Request) error {
// lock the backend's state - really just the config state - for mutating
b.mu.Lock()
defer b.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion builtin/credential/ldap/path_config_rotate_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (b *backend) pathConfigRotateRootUpdate(ctx context.Context, req *logical.R

b.mu.RUnlock()

err = b.RotatePassword(ctx, req)
err = b.RotateCredential(ctx, req)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions builtin/logical/aws/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func Backend(_ *logical.BackendConfig) *backend {
},

// placeholder
RotatePassword: func(ctx context.Context, request *logical.Request) error {
fmt.Print("aws.RotatePassword called\n")
RotateCredential: func(ctx context.Context, request *logical.Request) error {
fmt.Print("aws.RotateCredential called\n")
return nil
},

Expand Down
11 changes: 6 additions & 5 deletions sdk/framework/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ type Backend struct {
// RunningVersion is the optional version that will be self-reported
RunningVersion string

// Functions for rotating the root password of a backend if it exists
RotatePassword func(context.Context, *logical.Request) error // specific backend developer responsible for handling basically everything
// RotateCredential is the callback function used by the RotationManager
// to communicate with a plugin on when to rotate a credential
RotateCredential func(context.Context, *logical.Request) error

logger log.Logger
system logical.SystemView
Expand Down Expand Up @@ -668,13 +669,13 @@ func (b *Backend) handleRollback(ctx context.Context, req *logical.Request) (*lo
return resp, merr.ErrorOrNil()
}

// handleRotation invokes the RotatePassword func set on the backend.
// handleRotation invokes the RotateCredential func set on the backend.
func (b *Backend) handleRotation(ctx context.Context, req *logical.Request) (*logical.Response, error) {
if b.RotatePassword == nil {
if b.RotateCredential == nil {
return nil, logical.ErrUnsupportedOperation
}

err := b.RotatePassword(ctx, req)
err := b.RotateCredential(ctx, req)
if err != nil {
return nil, err
}
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions sdk/logical/system_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type SystemView interface {
// GenerateIdentityToken returns an identity token for the requesting plugin.
GenerateIdentityToken(ctx context.Context, req *pluginutil.IdentityTokenRequest) (*pluginutil.IdentityTokenResponse, error)

// RegisterRotationJob returns a rotation ID for a requested plugin credential.
RegisterRotationJob(ctx context.Context, reqPath string, job *RotationJob) (rotationID string, err error)
}

Expand Down Expand Up @@ -288,7 +289,6 @@ func (d StaticSystemView) APILockShouldBlockRequest() (bool, error) {
return d.APILockShouldBlockRequestVal, nil
}

func (d StaticSystemView) RegisterRotationJob(ctx context.Context, reqPath string, job *RotationJob) (rotationID string, err error) {
return "", nil
// return "", errors.New("RegisterRotationJob is not implemented in StaticSystemView")
func (d StaticSystemView) RegisterRotationJob(_ context.Context, _ string, _ *RotationJob) (rotationID string, err error) {
return "", errors.New("RegisterRotationJob is not implemented in StaticSystemView")
}
7 changes: 0 additions & 7 deletions sdk/plugin/pb/backend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,6 @@ message RotationJobInput {
string name = 4;
}

//message RotationScheduleInput {
// google.protobuf.Struct schedule = 1;
// google.protobuf.Duration rotation_window = 2;
// string rotation_schedule = 3;
// google.protobuf.Struct next_vault_rotation = 4;
//}

// SystemView exposes system configuration information in a safe way for plugins
// to consume. Plugins should implement the client for this service.
service SystemView {
Expand Down
2 changes: 1 addition & 1 deletion vault/dynamic_system_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func (d dynamicSystemView) RegisterRotationJob(ctx context.Context, reqPath stri
path = ns.Path + "/" + reqPath
}

id, err := d.core.rotationManager.Register(namespace.ContextWithNamespace(ctx, job.Namespace), path, job)
id, err := d.core.RegisterRotationJob(namespace.ContextWithNamespace(ctx, job.Namespace), path, job)
if err != nil {
return "", fmt.Errorf("error registering rotation job: %s", err)
}
Expand Down
Loading
Loading